Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,
I have quiet delicate problem with regional settings... hope somebody knows the answer.

I have MS Access database and there is a table linked from SharePoint.
I am using UK regional settings and that SharePoint is set with German regional settings.
When I open the DB and open that table numbers in it are 100 times greater then it should be.
The reason for this is because "." (dot) in UK is used for digital grouping (separate thousands) and "." (dot) in Germany is used for decimal places...
So - German 10.11 (Ten point eleven) is 1011 (One thousand and eleven) in UK.
I have tried starting MS access in separate thread using CultureInfo, but that made no difference.
C#
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

C#
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
If I start the MessageBox - it shows in correct regional settings as I set with CultureInfo, but when I start the application (Access, Excel, etc.) - it opens in the original user settings...
Does anyone know a way ho to change user's regional settings with C# somehow?

P.S.: I know that it's not recommended practice, but sometime we have to do what we have to.

Thanks everyone!
Posted
Updated 21-Feb-13 1:44am
v2
Comments
Jegan Thiyagesan 21-Feb-13 8:22am    
Hi,
Uk = Europe
12,345.67 = 12.345,67

regardless of how the number are displayed the database will always store in InvarientCulture that is 12,345.67, BUT when its read, the reader converts to the current culture. As you said that the SharePoint is in German Culture, when its read the database, it will immediately convert to German culture.

The solution would be to force the SharePoint use the InvarientCulture.
MK-Gii 21-Feb-13 9:40am    
Your answer
Thanks for the reply Jegan, but this is not possible to alter SharePoint. We have to use what we have. Also that column, holding the numbers, is type of "Single line of text" meaning that each time we take the data - we typecast it into double value.
I was trying to force SharePoint admin to "move his ass and fix it", but.... I am hardly the one who calls the shots here and still have to work with it.
So far the only solution to this I could fing was to change user regional settings directly... and I just don't know how :)

1 solution

Thanks for the reply Jegan, but this is not possible to alter SharePoint. We have to use what we have. Also that column, holding the numbers, is type of "Single line of text" meaning that each time we take the data - we typecast it into double value.
I was trying to force SharePoint admin to "move his ass and fix it", but.... I am hardly the one who calls the shots here and still have to work with it.
So far the only solution to this I could fing was to change user regional settings directly... and I just don't know how :)

Thanks again guys!
 
Share this answer
 
Comments
Jegan Thiyagesan 21-Feb-13 10:08am    
What do you mean by change user setting directly? did you mean in your PC?
MK-Gii 21-Feb-13 23:43pm    
Not exactly - it should change the settings on the current PC the program is running. It might be one of the 3 PC. The thing I am trying to achieve is as follows:
1. Change regional settings to "de-DE"
2. Import data in the correct format.
3. Change regional settings back to what it was before.
Jegan Thiyagesan 22-Feb-13 4:18am    
In this case,
When you read the data from database, why don't you read it as InvariantCulture.
MK-Gii 25-Feb-13 4:42am    
Hello Jegan.
I am not readiong the data from database actually - I am running the macro, which is in AccessDB. And that macro takes data from one table, processes it and puts into another table. The problem, as I mentioned before, is that the data is stored in SharePoint and numbers stored as text.
When macro runs - it automatically typecasts this into numeric value. In this case regional settings are very important because dots (.) are used for decimal symbols and commas (,) for digital grouping.
As for the InvariantCulture - do you accidentaly have some usufull link with example for a newby?
Thanks a lot, Jegan!
Jegan Thiyagesan 25-Feb-13 5:26am    
Have you tried this in your program:
Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

See link in stackoverflow:

http://stackoverflow.com/questions/12729922/how-to-set-cultureinfo-invariantculture-default

My concern is that, that the Sharepoint is set to German culture, this may over write any of your settings at the point when the data is read from Sharepoint. This is a tricky scenario!

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