Link to home
Start Free TrialLog in
Avatar of TaibaDXB
TaibaDXB

asked on

SQLHelper Problem with Decimal DataType

Hi.
I have a strange problem with SQLHelper from the Enterprise Library.
I am using a statement like the following:

SqlHelper.ExecuteScalar(SqlHelper.ConnStr, "InsertTotalAmount", TotalAmount);

The InsertTotalAmount SP will insert the TotalAmount to a field with Decimal(38,23) Type.
This statement works fine with values less than 99999, but gives me an error with greater than 99999, the error is: "Conversion overflows".
The Decimal(38,23) Type should be enough for storing values like: 1,000,000 !!
what is worng with SQLHelper?
Avatar of cdaly33
cdaly33
Flag of United States of America image

What happens if you run the stored proc on its own using the same values?  Are you doing any multiplication or division in the stored proc which might affect the accuracy of the decimal?
Avatar of TaibaDXB
TaibaDXB

ASKER

Hi.
if I run the stored proc directly with the same values, it rus correctly without any problems!!
The stored proc just inserts the value into the table without doing any arithmatic operation.
Thanks for you rhelp.
Can you post the declaration and assignment of TotalAmount?
Hi.
Total amount is declared in .NET as Decimal.
Its value is entered by the user like the following:
Decimal totalAmount = Convert.ToDecimal(txtTotalAmount.Text);
In SQL Server 2008 it is declared in the table as : decimal(38,23)
ASKER CERTIFIED SOLUTION
Avatar of TaibaDXB
TaibaDXB

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wow, great find.  That's great to know.