Connecting Tech Pros Worldwide Forums | Help | Site Map

Decimal rounding problem

Rick Gabel
Guest
 
Posts: n/a
#1: Nov 16 '05
Trying to use the decimal datatype with SQL Server2000 and C#.Net and having
a rounding problem.

I am using SqlCommand/SqlParameter process to retrieve and insert a record
into the table. One of the columns is a decimal and it is defined with the
precision/scale of 18,2. I am passing the value back using "ref decimal".

When I try to retrieve a value from the table with the value of 12.34, I get
12. Or I get 51 when the value should be 50.65. It appears that ADO is
rounding the values to/from the database. The same thing is happening with
insert.

As a side experiment, I changed the datatype to Money in the database.
(Changed the SqlParameter dbtype to SqlDbType.Money and removed the scale
and precision settings also). The retrieval would work correctly but the
insert was still rounding the value.

Any ideas would be greatly appreciated.
Rick



Closed Thread


Similar C# / C Sharp bytes