Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Decimal returning as Integer
Message
De
13/10/2010 10:20:36
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01485249
Message ID:
01485287
Vues:
28
>>>>>In additon, always specify precision when casting to decimal!
>>>>>
>>>>>See this blog post
>>>>>
>>>>>Always specify precision with decimal and numeric
>>>>
>>>>The problem was the precision in my casting, I had left off the (18,2).
>>>>
>>>>Thanks
>>>
>>>Glad to help.
>>
>>Aargh! Now it seems to still be coming across to .NET as 70.
>>
>>This is my code:
>>
>>
            // Create the parameter and set the direction
>>            Decimal defaultValue = 0.00M;
>>            IDbDataParameter param1 = this.CreateParameter("@PolicyHeaderPK", policyHeaderFK);
>>            IDbDataParameter param2 = this.CreateParameter("@SuspenseAmount", defaultValue);
>>            param2.Direction = ParameterDirection.Output;
>>
>>            // Call the stored procedure and pass the parameter
>>            IDbCommand cmd;
>>            this.ExecSprocScalar("PoliciesGetSuspenseAmount", out cmd, param1, param2);
>>
>>            // Retrieve the value from the command object
>>            IDbDataParameter param = (IDbDataParameter)cmd.Parameters["@SuspenseAmount"];
>>            Decimal suspenseAmount = (Decimal)param.Value;
>>
>>            return suspenseAmount;
>>
>>param.Value is definitely 70 whereas the stored procedure is returning 69.57.
>
>Here you're probably having the same problem. You need to specify type and precision in the param2 line. Verify CreateParameter method and if it allows to specify the type with the precison.

That's a distinct possibility! There is a param.Precision property, but I have no idea how I'm supposed to set it. I'll ask in the MM.NET section and see if I can get a response.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform