Last post Dec 16, 2014 01:28 PM by Glenn Saint
Dec 16, 2014 12:27 PM|cplusplus1|LINK
I have the following for Refvalue= 34.14, i alwasy will have numeric value with two decimals. but it is coming as string.
Back end db table the SequenceNo column = REAL defined as.
lstParameterRM.Add(new SqlParameter("SequenceNo", Refvalue));
Thanks a lot for the helpful info
Dec 16, 2014 12:33 PM|imapsp|LINK
lstParameterRM.Add(new SqlParameter("SequenceNo", Decimal.Parse(Refvalue)));
Hope this helps.
Dec 16, 2014 12:34 PM|Glenn Saint|LINK
Hi there, try Convert.ToDouble(Refvalue);
Dec 16, 2014 12:55 PM|Rion Williams|LINK
You'll basically just need to use one of the many available numerical parsing methods (such as
Double.Parse() etc.). This will allow you to convert your stringified value into the appropriate type, which you can then use to pass into your query :
// Convert your value (using one of the recommended approaches mentioned earlier)
var refValue = Decimal.Parse(Refvalue);
// Pass your value in as a parameter
Dec 16, 2014 01:28 PM|Glenn Saint|LINK
Also you might want to check out SQL Server Data Type Mappings and its equivalent type in .NET. Dealing with numbers with decimal places, depends on how you want to store the
data and its precision, if your concern about decimal places and precision consider checking out the link otherwise your can choose one of the numerical parsing methods.