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(Sq lHelper.Co nnStr, "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?
I have a strange problem with SQLHelper from the Enterprise Library.
I am using a statement like the following:
SqlHelper.ExecuteScalar(Sq
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?
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?
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.
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?
ASKER
Hi.
Total amount is declared in .NET as Decimal.
Its value is entered by the user like the following:
Decimal totalAmount = Convert.ToDecimal(txtTotal Amount.Tex t);
In SQL Server 2008 it is declared in the table as : decimal(38,23)
Total amount is declared in .NET as Decimal.
Its value is entered by the user like the following:
Decimal totalAmount = Convert.ToDecimal(txtTotal
In SQL Server 2008 it is declared in the table as : decimal(38,23)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Wow, great find. That's great to know.