G
Guest
Hi everyone,
I wrote a store procedure that fetch one row data in the database based on
the parameter value I entered. After I created the store procedure,
the store procedure code looks like this:
ALTER proc getProductCommScale @product As varchar(30), @TISCommRate As
Decimal(5,2) OUTPUT,
@BrokerCommRate As Decimal(5,2) OUTPUT, @Fee As Decimal(5,2) OUTPUT
As
if RTRIM(@product)='Imed'
Select @TISCommRate=TISComm, @BrokerCommRate=BrokerComm, @Fee=Fee
from tis_productCommScale where ProductName='Imed'
select @TISCommRate , @BrokerCommRate, @Fee
Return
an dthen I tested in the database with the following code:
Declare @TISCommRate As Decimal(5,2)
Declare @BrokerCommRate As Decimal(5,2)
Declare @Fee As Decimal(5,2)
exec getProductCommScale 'Vusa',@TISCommRate, @BrokerCommRate, @Fee
Then I got the following data:
..35 .20 5.00
But it seems not working in asp.net(1.1), here is part of my .net coding:
Dim sqlConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings(Global.CfgKeyConnString))
Dim myCommand As SqlCommand = New
SqlCommand("GetProductCommScale", sqlConnection)
myCommand.CommandType = CommandType.StoredProcedure
Dim pProduct As SqlParameter = New SqlParameter("@Product",
SqlDbType.VarChar, 30)
pProduct.Value = product
myCommand.Parameters.Add(pProduct)
Dim pTisCommRate As SqlParameter = New
SqlParameter("@TISCommRate", SqlDbType.Decimal)
pTisCommRate.Precision = 5
pTisCommRate.Scale = 2
pTisCommRate.Direction = ParameterDirection.Output
myCommand.Parameters.Add(pTisCommRate)
Dim pBrokerCommRate As SqlParameter = New
SqlParameter("@BrokerCommRate", SqlDbType.Decimal)
pBrokerCommRate.Precision = 5
pBrokerCommRate.Scale = 2
pBrokerCommRate.Direction = ParameterDirection.Output
myCommand.Parameters.Add(pBrokerCommRate)
Dim pFee As SqlParameter = New SqlParameter("@Fee",
SqlDbType.Decimal)
pFee.Precision = 5
pFee.Scale = 2
pFee.Direction = ParameterDirection.Output
myCommand.Parameters.Add(pFee)
sqlConnection.Open()
Dim reader As SqlDataReader = myCommand.ExecuteReader()
Dim TisCommRate As Decimal = Convert.ToDecimal(pTisCommRate.Value)
But somehow I always get nothing from pTisCommRate.Value, same to the other
parameters. What's going on? I am just learning to get data from output
parameters, did I miss anything?
I wrote a store procedure that fetch one row data in the database based on
the parameter value I entered. After I created the store procedure,
the store procedure code looks like this:
ALTER proc getProductCommScale @product As varchar(30), @TISCommRate As
Decimal(5,2) OUTPUT,
@BrokerCommRate As Decimal(5,2) OUTPUT, @Fee As Decimal(5,2) OUTPUT
As
if RTRIM(@product)='Imed'
Select @TISCommRate=TISComm, @BrokerCommRate=BrokerComm, @Fee=Fee
from tis_productCommScale where ProductName='Imed'
select @TISCommRate , @BrokerCommRate, @Fee
Return
an dthen I tested in the database with the following code:
Declare @TISCommRate As Decimal(5,2)
Declare @BrokerCommRate As Decimal(5,2)
Declare @Fee As Decimal(5,2)
exec getProductCommScale 'Vusa',@TISCommRate, @BrokerCommRate, @Fee
Then I got the following data:
..35 .20 5.00
But it seems not working in asp.net(1.1), here is part of my .net coding:
Dim sqlConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings(Global.CfgKeyConnString))
Dim myCommand As SqlCommand = New
SqlCommand("GetProductCommScale", sqlConnection)
myCommand.CommandType = CommandType.StoredProcedure
Dim pProduct As SqlParameter = New SqlParameter("@Product",
SqlDbType.VarChar, 30)
pProduct.Value = product
myCommand.Parameters.Add(pProduct)
Dim pTisCommRate As SqlParameter = New
SqlParameter("@TISCommRate", SqlDbType.Decimal)
pTisCommRate.Precision = 5
pTisCommRate.Scale = 2
pTisCommRate.Direction = ParameterDirection.Output
myCommand.Parameters.Add(pTisCommRate)
Dim pBrokerCommRate As SqlParameter = New
SqlParameter("@BrokerCommRate", SqlDbType.Decimal)
pBrokerCommRate.Precision = 5
pBrokerCommRate.Scale = 2
pBrokerCommRate.Direction = ParameterDirection.Output
myCommand.Parameters.Add(pBrokerCommRate)
Dim pFee As SqlParameter = New SqlParameter("@Fee",
SqlDbType.Decimal)
pFee.Precision = 5
pFee.Scale = 2
pFee.Direction = ParameterDirection.Output
myCommand.Parameters.Add(pFee)
sqlConnection.Open()
Dim reader As SqlDataReader = myCommand.ExecuteReader()
Dim TisCommRate As Decimal = Convert.ToDecimal(pTisCommRate.Value)
But somehow I always get nothing from pTisCommRate.Value, same to the other
parameters. What's going on? I am just learning to get data from output
parameters, did I miss anything?