regional settings, .Net & DB

G

Guest

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?
 
C

Cor Ligthert

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/d...dataoledboledbcommandclassparameterstopic.asp

I hope this helps?

Cor
 
G

Guest

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....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top