Last post Sep 29, 2011 05:35 AM by Yasser Shaikh
Sep 29, 2011 02:59 AM|yasser shaikh|LINK
I'm am reading a xml file and inserting node values into the database. When I checked my insert on my local machine it worked fine, ( eg: 12.6 was inserted as 12.6) but when I checked the same thing on server ( machine in Denmark with Danish settings) the
same value 12.6 was inserted as 126.0
I am aware that a ',' corresponds to a decimal point '.' and vice versa in denmark.
When I checked using sql profiler, the values reached to the stored procedure itslef was not correct. i.e 12.6 was as 126, the variable type in my code is decimal?.
And the dataType in the database is decimal(18,2);
What can I do with this ?
Thanks in advance
Sep 29, 2011 05:13 AM|chiragvidani|LINK
When you are fetching the data from xml nodes its in culture specific, so you need to convert to english format first and then insert the same in database.
Decimal.Parse("12,3",new System.Globalization.CultureInfo("<Your culture of denmark here>"))
//as de-DE is for germany
For further information refer this http://msdn.microsoft.com/en-us/library/t7xswkc6.aspx#Y911
Sep 29, 2011 05:35 AM|yasser shaikh|LINK
Thanks that helped.