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 42 Answers
For decimal you 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 SqlParameter MSDN page have arguments for precision and scale.
Hello you can try with Scale in order to format your parameter
SqlParameter parameter = new SqlParameter("miles", SqlDbType.Decimal); parameter.Scale = 2; //The number of positions 2