By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

regional settings, .Net & DB

P: n/a
doing some research on regional settings, .Net & DB
I put my machine in Germany(Germany)
thus the decimal char = ","
the seperator char = "."
so I set up the database for a test in .Net
I'm using Access.
a field (double) contains 45,56

I read the record using DataReader

then I did a read:

mVariable = .GetDouble(TheOrdinalPos)
mVariable shows "45.56" which means the comma got translate to the period.
on the Update, myActionQuery is.......
myActionQuery = "UPDATE Table1 SET Fld1 = " & mVariable & " Where Id = " & Id
....................
myCommand.CommandText = myActionQuery
myActionQuery shows
"UPDATE Table1 SET Fld1 = 45,56 Where Id = 10"

notice the 45.56 was turned into 45,56 (that's with a comma for the
decimal character)

but on the actual execute command,
numOfRecordsUpdated = myCommand.ExecuteNonQuery()
it caused a trap.... invalid statement

but when I changed from Germany to English and reran the code, with no code
changes, same scenario
the UPDATE worked...

I am obviously missing something dealing with Regional setting... can some
one fill me in?
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
JohnK,

I cannot see what is mVariable, I assume a string.

"UPDATE Table1 SET Fld1 = " & mVariable & " Where Id = " & Id

Why you think that the comma should be in the German language while the rest
is all (US) English.

It is just an SQL command from which we can often read that it is in a for
everybody normal way written, and therefore for everybody easy to understand
(and than forget that only less than 8% of the world populations can write
English).

However, for this are the oledbparameters

http://msdn.microsoft.com/library/de...eterstopic.asp

I hope this helps?

Cor
Jul 21 '05 #2

P: n/a
my machine is set to Germany(Germany)

mVariable is of type double

when I build the query string,
"UPDATE Table1 SET Fld1 = " & mVariable & " Where Id = " & Id
the resulting query string ends up being:
"UPDATE Table1 SET Fld1 = 45,56 Where Id = 10"
the string is obviously build using cultural settings....

obviously either ADO or Access does not like that query string as it traps.

but if I put my machine in English regional settings
"UPDATE Table1 SET Fld1 = " & mVariable & " Where Id = " & Id
the resulting query string ends up being:
"UPDATE Table1 SET Fld1 = 45.56 Where Id = 10"
works fine.

Since I have no control over the end user's machine's regional settings
I need to be able to build the query string such that ADO/Access does not
complain about it....
Jul 21 '05 #3

P: n/a
John,

I know, however I showed you the proper method to use those parameters..

UPDATE Table1 SET Fld1 =? Where Id =?"

And than create the parameter collection in the right sequense.

http://msdn.microsoft.com/library/de...eterstopic.asp

Why don't you use that proper method?

Cor
Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.