views:

1167

answers:

5

Context: I'm in charge of running a service written in .NET. Proprietary application. It uses a SQL Server database. It ran as a user member of the Administrators group in the local machine. It worked alright before I added the machine to a domain.

So, I added the machine to a domain (Win 2003) and changed the user to a member of the Power Users group and now, the

Problem: Some of the SQL sentences it tries to execute are "magically" in spanish localization (where , separates floating point numbers instead of .), leading to errors.

There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

Operating System and Regional Settings in the machine are in English. I asked the provider of the application and he said:

Looks like you have a combination of code running under Spanish locale, and SQL server under English locale. So the SQL expects '15.28' and not '15,28'

Which looks wrong to me in various levels (how can SQL Server distinguish between commas to separate arguments and commas belonging to a floating point number?).

So, the code seems to be grabbing the spanish locale from somewhere, I don't know if it's the user it runs as, or someplace else (global policy, maybe?). But the question is

What are the places where localization is defined on a machine/user/domain basis?

I don't know all the places I must search for the culprit, so please help me to find it!

+1  A: 

You can set it in the thread context in which your code is executing.

System.Threading.Thread.CurrentThread.CurrentCulture

Will
+3  A: 

There are two types of localisation in .NET, both the settings for the cultures can be found in these variables (fire up a .NET command line app on the machine to see what it says):

System.Thread.CurrentThread.CurrentCulture & System.Thread.CurrentThread.CurrentUICulture

http://msdn.microsoft.com/en-us/library/system.threading.thread_members.aspx

They relate to the settings in the control panel (in the regional settings part). Create a .NET command line app, then just call ToString() on the above properties, that should tell you which property to look at.

Edit:

It turns out the setting for the locales per user are held here:

HKEY_CURRENT_USER\Control Panel\International

It might be worth inspecting the registry of the user with the spanish locale, and comparing it to one who is set to US or whichever locale you require.

Mark Ingram
A: 

Great, I created the console app and indeed, the app is not crazy, CurrentCulture is in spanish, but for THAT User in THAT machine only. If I run the console app as another user it returns english for all cultures.

Should I open a new question asking where are user-wise locale settings?

Vinko Vrsalovic
If you feel my answer answers your original question, then finish this and start a new question. Either way I'll try to get the answer and post it here :)
Mark Ingram
A: 

Well if it's user specific, check out the Regional and Language Options control panel.

<rant>On a side note, kick the developer for not being culture aware when using strings.</rant>

Ant
A: 

Found out why it happened in that machine only. It was the only one where I actually logged into with that user, then the domain controller set the regional settings as spanish for it.

Vinko Vrsalovic