Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem getting Decimal value from Recordset

Status
Not open for further replies.

jby1

Programmer
Apr 29, 2003
403
0
0
GB
Hi

I am having an usse retrieving a decimal value from a recordset, and putting it into a C# decimal type.

I am using the following code to do this (recordset is called dr):

Code:
decimal decNum = decimal.Parse(dr["decFld"].ToString());

If the decimal number is 10,000,000 or greater, then it causes a parse error. I think this is because from this size of number, it is returned in scientific notation and thus the parse method cannot handle it.

I have worked out that if I use
Code:
convert(decimal, decFld)
in the SQL stored procedure, it seems to fix the problem, but I would rather come up with a C# based fix. Any ideas?
 
It is ok, I have sorted it out. Turns out that the database designer had used a real datatype instead of a decimal, which caused the problem. It is now set to be a decimal and working fine!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top