Open
Description
Hi Joel,
I cannot change the regional settings the SQL Server and the computers have to use here. The SQL Server variable @@language returns 'Deutsch' and the regional settings are also German ("de-DE").
The following problems were encountered when running Test.SqlServer:
- Wrong format for the datetime strings. This happened during insert. The cure was to add "Current Language=us_english; " to the connection string.
- Now the format of the number 123.456 was "123,456" in the German locale and it was of course wrong for the SQL Server. This was fixed by adding the following to the beginning of Main:
System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
I can think of the following options:
- Use the abovementioned fixes. I am not sure about alphabetical ordering; the initial tests show that it might work.
- Check all the uses of ToString() and put System.Globalization.CultureInfo.InvariantCulture everywhere.
- Create a function to format datetimes and strings according to the column type (as fetched from the database) and the CultureInfo.InvariantCulture.
- Skip conversion to string by stashing everything to query parameters. This makes debugging queries harder than it needs to be. On the plus side, all conversion woes should disappear and the library will tolerate any locale settings on both user side and SQL Server side.
There is a related problem, namely, I cannot insert into tables with columns of type "datetime", because there are too many decimal points and the SQL Server cannot convert it. Although the decimal points are zeroes, but still. Maybe just drop the extra zeroes?
Which options of the above are "no-no"? Is there any "right" solution? I would give implementing it a try.
I would be happy for all the input.
Metadata
Metadata
Assignees
Labels
No labels