Click here to Skip to main content
15,850,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My SQL DB has US culture settings but I'm based in EU.
In my gridview $ and mdy date format is shown ( also . and , are swapped in numbers).
Can I set the EU formats on these fields somehow?

setting the culture to nl-BE in my website does not help.


thank you for your help.
Posted

How can it possibly currency setting affect database server operation. You should store numbers, not strings representing numbers, no matter is that currency of not. And numbers, by their nature, are culture-neutral. You need to take care of the presentation of the numbers in ASP.NET, and set the threads to required cultures.

Actually, MySQL does have culture-related settings, but it's mostly related to the calendar: http://dev.mysql.com/doc/refman/5.0/en/locale-support.html[^]http://dev.mysql.com/doc/refman/5.0/en/locale-support.html[^].

Also note that dollars remain dollars even if they are written in different culture. It all depends on what you calculate. If you only calculate the currency of only one kind, you don't even need to carry information on what the units are. And if you do operate with different currency units, the real issue is the (ever changing) rates.

It's not clear how "setting the culture to nl-BE in my website does not help". How come? Of course it does help, but the culture comes into play when you format number for showing them on screen. Please see:
http://msdn.microsoft.com/en-us/library/system.threading.thread.currentculture(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.threading.thread.currentuiculture(v=vs.110).aspx[^].

If you do it, you will see that numeric data formatting is affected by the culture choice. Please see all the ToString methods of the numeric type(s) you use.
See also:
http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.positiveinfinitysymbol(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.negativeinfinitysymbol(v=vs.110).aspx[^].

This is how you get your currency symbol: http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.currencysymbol%28v=vs.110%29.aspx[^].

This way, your application can be globalized. You don't have to hard-code dollar or euro characters, you can set current culture as required and get the default currency symbol.

—SA
 
Share this answer
 
Comments
[no name] 7-Nov-14 17:55pm    
I'll take this. Thank you, my small 5. Bruno
Sergey Alexandrovich Kryukov 7-Nov-14 19:11pm    
Thank you, Bruno.
—SA
Eddy Sels 8-Nov-14 11:12am    
I will read all the links you mention. Thank you for that.
But be aware in MS SQL database you can have a field with type 'smallmoney'.
the data returned is culture dependent. I don't know why this is or which culture setting prevails (database server, web server). In any case not the web site because then I would not have the issue.
I tested my site in Azure where I did not have the issue because the servers have a culture which matches my own. Since I went live on a US based webhosting my currency, number and date formats are in the US culture.

I tried the ToString but sometimes (I haven't figured out why) I get an error in VS2013 saying ToString has no overload which takes 3 arguments.
BTW I use numbers not strings.
Sergey Alexandrovich Kryukov 8-Nov-14 21:39pm    
Good. As to ToString, just check up the signatures you can use. You try to use non-existing one.
—SA
I was setting the culture in my code, but the culture was not set. I modified the code and now it is ok. So it was a bug in my code.
I figured it out by adding a label on my start page with the current culture info.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900