Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returned param value has no decimals
Message
From
28/01/2008 09:30:32
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Returned param value has no decimals
Miscellaneous
Thread ID:
01286059
Message ID:
01286059
Views:
75
I am having a problem getting decimal values from a stored procedure. The SQL stored procedure works correctly in SQL Query Analyzer and prints a value of say 17.25.

When I use the following in VB.NET the answer (param.value) returns 17D with no decimals.
  'Get sum of items
  Public Function GetItemCostSum(ByVal lnReqID As Integer) As Decimal
    'Create the parameter and set the direction
    Dim param2 As IDbDataParameter = Me.CreateParameter("@ItemSum", 0)
    param2.Direction = ParameterDirection.Output
    Dim param1 As IDbDataParameter = Me.CreateParameter("@ReqID", lnReqID)
    param1.Direction = ParameterDirection.Input

    'Call the stored procedure and pass the parameter(s)
    Dim cmd As IDbCommand = Nothing
    Me.ExecSprocScalar("GetItemCostSum", cmd, param1, param2)

    'Retrieve the value from the command object
    Dim param As IDbDataParameter = CType(cmd.Parameters("@ItemSum"), IDbDataParameter)
    param.DbType = DbType.Currency
    param.Precision = 11  'Length = 9 + Scale = 2
    param.Scale = 2 'Decimal places
    Dim lnSubItems As Decimal
    lnSubItems = CDec(param.Value)
    Return lnSubItems
  End Function
Can anyone tell me if the syntax is wrong or what I am doing wrong?

Thanks.
Next
Reply
Map
View

Click here to load this message in the networking platform