Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returned param value has no decimals
Message
De
28/01/2008 09:30:32
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Returned param value has no decimals
Divers
Thread ID:
01286059
Message ID:
01286059
Vues:
76
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.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform