all groups > dotnet internationalization > june 2007 >
You're in the

dotnet internationalization

group:

Difficult internationalization problem to solve


Difficult internationalization problem to solve UW
6/15/2007 9:05:00 AM
dotnet internationalization:
I am working on internationalizing legacy VB component which was ported out to
VB.Net This code base is very old and it does something no body recommends
in the data service component. Changing the way it works is not an option
so no point discussing that here.

The problem is SQL query is dynamically generated in the data service
component by
doing a simple string concatenation. Being VB it doesn’t even do proper
casting
it just attaches it string query. It has been working fine last 10 years
and this year
they decided to internationalize the code base. The SQL query breaks when
locale
is set to languages that uses comma instead of period as decimal. For example

INSERT INTO PURCHASING (COL1, COL2) VALUES (123.45, ‘TEST’)

Now becomes

INSERT INTO PRUCHASING (COL1, COL2) VALUES (123,45, ‘TEST’)

This is not a proper SQL query. This happens because conversion of double
to string includes locale formatting and since every assembly runs in a same
thread monolithically I can not even use tricks like resetting the running
thread
culture (it will disrupt formatting and currency display). How can I so that
SQL query is generated right?

Thank you.
Re: Difficult internationalization problem to solve UW
6/15/2007 11:11:02 AM
Thank you for your response.

Is there any 'trick' or 'gimmick' I can use without add/change existing
code?

For example :

add attributes in the assembly info file and fix the assembly
in certain
culture.

or

change somthing in the .Net config file to apply above effect
or
some how redefine way .Net handles certain casting (this will
effect
how UI displays numbers so need way to get around that as well
if works)

Any ideas? Would contacting Microsoft support have better idea?

Thank you.

[quoted text, click to view]
Re: Difficult internationalization problem to solve Michael Nesslinger
6/15/2007 7:39:26 PM
UW schrieb:
[quoted text, click to view]
If i got you right, you can use this to transform your double values
into the right language:

Dim dbl As Double = 1.2
Dim en As New CultureInfo("en-GB")

Console.WriteLine("With CultureInfo: {0}", Convert.ToString(dbl, en))
Console.WriteLine("Without CultureInfo: {0}", dbl)

Re: Difficult internationalization problem to solve Jochen Kalmbach [MVP]
6/16/2007 12:00:00 AM
Hi UW!


[quoted text, click to view]

This is the main problem! Never ever do string-concatenattion! This will
open a wide door for SQL-injections!
Pass your parameters as "Parameters"!

Unnamned-Parameters:
INSERT INTO PURCHASING (COL1, COL2) VALUES (?, ?)

Names-Parameters:
INSERT INTO PURCHASING (COL1, COL2) VALUES (@col1, @col2)


Then you don't have this problem anymore!

[quoted text, click to view]

You could use x.ToString(Culture.InvariantCulture)


--
Greetings
Jochen

My blog about Win32 and .NET
AddThis Social Bookmark Button