converting string to decimal shows error
-
System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Decimal.Parse(String s, IFormatProvider provider) at System.Convert.ToDecimal(String value) at test.Button1_Click(Object sender, EventArgs e) in e:\MyProject\DOTNET2005\HR2005\test.aspx.cs:line 30
All I ever wanted is what others have....
CrazySanker -
System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Decimal.Parse(String s, IFormatProvider provider) at System.Convert.ToDecimal(String value) at test.Button1_Click(Object sender, EventArgs e) in e:\MyProject\DOTNET2005\HR2005\test.aspx.cs:line 30
All I ever wanted is what others have....
CrazySankerFormatException in System.Convert.ToDecimal(String value) means: value does not consist of an optional sign followed by a sequence of digits (zero through nine) and an optional decimal point symbol. Check if: - the String to convert has no invalid chars (letters etc.) - the String has the right delimiter for the used local settings (you can set the Culture with Convert.ToDecimal Method (String, IFormatProvider) ). Maybe just put the string before converting to the trace so you can see the value used (or set a breakpoint). Hope that helps Roland
Hi! I'm a signature virus. Copy me into your sig file and help me spread!
-
FormatException in System.Convert.ToDecimal(String value) means: value does not consist of an optional sign followed by a sequence of digits (zero through nine) and an optional decimal point symbol. Check if: - the String to convert has no invalid chars (letters etc.) - the String has the right delimiter for the used local settings (you can set the Culture with Convert.ToDecimal Method (String, IFormatProvider) ). Maybe just put the string before converting to the trace so you can see the value used (or set a breakpoint). Hope that helps Roland
Hi! I'm a signature virus. Copy me into your sig file and help me spread!
hi, Thank you for your reply I detetct the problem. It was,in default my machine support "," instead of "." in decimal values. How can i slove it??? i upgraded asp.net1.0 application to asp.net2.0. In my applcation I am using convert.toDecimal function in numerous place. how i solve it??
All I ever wanted is what others have....
CrazySanker -
hi, Thank you for your reply I detetct the problem. It was,in default my machine support "," instead of "." in decimal values. How can i slove it??? i upgraded asp.net1.0 application to asp.net2.0. In my applcation I am using convert.toDecimal function in numerous place. how i solve it??
All I ever wanted is what others have....
CrazySankerstring a = "12.85"; decimal da = System.Convert.ToDecimal(a, System.Globalization.CultureInfo.InvariantCulture); string b = "12,85"; decimal db = System.Convert.ToDecimal(b, new System.Globalization.CultureInfo("de-DE")); hope that helps Roland
Hi! I'm a signature virus. Copy me into your sig file and help me spread!