Which datatype should I be using to give me a number with 2 decimal places?
I currently have the following line:
command.Parameters.Add("@miles", SqlDbType.Decimal, 2).Value = miles;
and I am not sure what SqlDbType.Decimal, 4 means in terms of decimal places?
Will that allow the following
123.32
123321.67
and not allow numbers like
123
123.123321
543345.5434523
324.1
For
decimalyou need to specify both the precision and scale of the parameter.You do this by constructing the parameter (using
new) and adding it.The two last constructor overloads in the
SqlParameterMSDN page have arguments for precision and scale.