Hello Marc,
thanks for helping me again!
>I don't know much about DataTable(I've always steered fairly clear of
> DataSet), but if this was a regular SqlCommand (etc) I would be adding
> a parameter with .Value = aDoubleVar - that way, you don't need to
> worry about formatting, plus it is injection safe (think "Bobby
> Tables"...).
Yes, it would be preferable to use aDoubleVar parameter. Unfortunately in
order to do a select ( which is not a regualr SqlCommand ) on a dataTable
(see DataTable.Select) I must use a string, unless there I a feature in
DataTable I havn't met yet.
> However, if you /must/ use string concatenation, then you should
> ensure that the format is in the known, fixed, expected format of
<snip>
Well, the word "expected" in my question results of the information I
retreave from Thread.CurrentThread.CurrentCulture (en-US at that time) as I
set the breakpoint at the codeline in question. I in the meanwhile also
looked at
"Thread.CurrentThread.CurrentCulture.Numberformat.CurrentDecimalSeperator"
which also showed ".". Still the String.Format gave me a "," !
<snip>
> whatever you are talking to. It is *entirely reasonable* for the user
> to use their local (or /locale/) formats and separators, and your code
> shouldn't rely on this. This should be used for displaying data to the
> user, not exchanging data between systems. You could try passing
> CultureInfo.InvariantCulture as the first argument to string.Format
> (although you might need a more specific format...).
That "sounds" like a solution. I am a little hesitant, because (what I have
not mentioned yet) on of the requirements to my application is, that the
used language must be changable at runtime. Also it is a multithreaded
application (might be, that I still have some lacks here).
Would it be ok to only set Thread.CurrentThread.CurrentUICulture to what
ever the user wants and have the Thread.CurrentThread.CurrentCulture
internaly set to CultureInfo.InvariantCulture? Would this also work if
Parameters entered by the user in his Culture are processed by methods where
their thread is set to InvariantCulture?
Regards
Rainer
Marc Gravell - 06 Jan 2008 12:45 GMT
I wouldn't set the culture the invariant - I'd (as indicated) *use*
the invariant culture when I am doing system-to-system calls - i.e.
string.Format(CultureInfo.InvariantCulture, "foo", bar).
Note that there can be issues messing with culture while forms are
displayed; they don't like that much... a simpler option might be to
save the new culture in a settings file, and restart the app? (I
believe that Application has a Restart method or similar).
Also; re supplying proper parameters - I don't really know (not having
done it myself), but is this not the GetFillParameters method on the
data-adapter?
Marc
Rainer Queck - 06 Jan 2008 13:13 GMT
Hi Mark,
>I wouldn't set the culture the invariant - I'd (as indicated) *use*
> the invariant culture when I am doing system-to-system calls - i.e.
> string.Format(CultureInfo.InvariantCulture, "foo", bar).
Yes, that is what I am currently doing (ref my other answer/question).
> Note that there can be issues messing with culture while forms are
> displayed; they don't like that much... a simpler option might be to
> save the new culture in a settings file, and restart the app? (I
> believe that Application has a Restart method or similar).
It surely would be better, to set the culture and the stop/restart the
application. Unfortunately it is a request from my customer, that the app
must be able to switch rultures at runtime. Acutally this is working quite
good. I used the method pointed out in
http://dzaebel.net/LocalizeRuntime.htm by Frank Dzaeble.
> Also; re supplying proper parameters - I don't really know (not having
> done it myself), but is this not the GetFillParameters method on the
> data-adapter?
You are right, but I dont have a data-adapter, since I am working with a
"standalone" typed DataSet.
As mentioned above, I am already following your suggestion, and am using
CultureInfo.InvariantCulture to do my String.Format on selectStr generation.
It seems to be working fine, which leads me to the thought, that DataSets
are using CultureInfo.InvariantCulture internaly as well.
If someone could state this true, I can replace "seems to" with "is" ;-)
Regards
Rainer
Hi Marc,
>You could try passing
> CultureInfo.InvariantCulture as the first argument to string.Format
> (although you might need a more specific format...).
What kind of a Culture is a DataTable using for example on a select? Is it
possible, that it usese the "InvariantCulture" as well?
If that is the case, I could get rid of my problem by following your
suggestion. If not.... :-(
Regards
Rainer