ADO.NET decimal parameter
Posted on 2004-12-01
When i update my table i get some annoying rounding.
The SQL table has been set with a scale of 2 (ie 2 to the right of decimal point) If i set it manually in the DB it stays as expected.
Eg. 81.5 stays as 81.5
but when i try and update from my app it gets rounded... 81.5 becomes 82.
...in the dataset its held as i set it via the bound controls. I confirmed this by msgboxing it out..
So the problem lies with the parameters. At first i used the line below.
daProd.UpdateCommand.Parameters.Add(New SqlParameter("@PaymentForefit", SqlDbType.Decimal)).SourceColumn = "PaymentForefit"
Then i tried this other idea which incorporates the scale (set to 2). Still does work.
daProd.UpdateCommand.Parameters.Add(New SqlParameter("@PaymentForefit", SqlDbType.Decimal, _
9, ParameterDirection.Input, False, 18, 4, "PaymentForefit", _
I printed out @PaymentForefit from the storedprocedure... by then it has been rounded so its 82.