Why is the decimal SqlParameter getting distorted?

I send the decimal value to sproc as follows:

SqlParameter meh = new SqlParameter("Foo", SqlDbType.Decimal);
meh.Value = "0.00001";
meh.Precision = ((System.Byte)(12));
meh.Scale = ((System.Byte)(9));

When I look at a database to see what works with it, I see a parameter like this:

....,@Foo decimal(12,9),....,@Foo=10000,....

It seems to be completely mirrored from the decimal point, how can I fix this? Note that I also tried to convert the string to the actual decimal digit first and use it to set β€œmeh.Value”, but it still has the same problem.

Update

I noticed, as in the above example, that the original value has a decimal point shifted to the right by 9 positions, exactly the same value as the scale. What can cause this?

Updated again

I should note that I am using Sql Server 2008

+5
3

System.Byte SqlParameter? :

SqlParameter meh = new SqlParameter("Foo", SqlDbType.Decimal);
meh.Value = 0.00001;
meh.Precision = 12;
meh.Scale = 9;
+4

.

Microsoft ( ) :

http://support.microsoft.com/?kbid=892406

, .

EDIT: , , SqlParameter , , SqlCommand. SqlParameter SqlCommand, :

void parameterCheck(SqlCommand cmd, object value, int index, SqlDbType dataType) {
  cmd.Parameters[index].Value = value;
  if (dataType == SqlDbType.Decimal) {
    cmd.Parameters[index].Precision = 12;
    cmd.Parameters[index].Size = 9;
  }
}
+3

Why do you end the decimal value in quotation marks, turning it into a string?

0
source

All Articles