sourcecode for reginal settings problem oledb jet

S

Sander

Hello,

I think i am having the same problem here. This JScript source should
pinpoint the problem when Windows uses the "Dutch" regional settings.
Is this problem acknowledged and is there a workaround other then
using the Double floating point type or using a full MSDE
installation? We are building a product based upon .NET and the Jet
engine for the Dutch market. This problem seriously hinders our
program to work with decimal fields.

Thank you for your time!
Best regards,
Sander

---- Example sourcecode:

/* JScript - test.js
compile: jsc test.js
platforms tested: Win2K with Jet 4.00.8015.0 (SP 8) and WinXP

Works fine with "English (United States)" regional settings (decimal
seperator: .), however fails with "Dutch (Netherlands)" regional
settings (decimal seperator: ,)

THIS ALSO FAILS WITH VS.NET GENERATED C# DataAdapters

Unhandled Exception: System.Data.OleDb.OleDbException: The decimal
field's preci
sion is too small to accept the numeric you attempted to add.
at Microsoft.JScript.JSMethodInfo.Invoke(Object obj, BindingFlags
options, Bi
nder binder, Object[] parameters, CultureInfo culture)
at Microsoft.JScript.LateBinding.CallOneOfTheMembers(MemberInfo[]
members, Ob
ject[] arguments, Boolean construct, Object thisob, Binder binder,
CultureInfo c
ulture, String[] namedParameters, VsaEngine engine)
at Microsoft.JScript.LateBinding.Call(Binder binder, Object[]
arguments, Para
meterModifier[] modifiers, CultureInfo culture, String[]
namedParameters, Boolea
n construct, Boolean brackets, VsaEngine engine)
at Microsoft.JScript.LateBinding.Call(Object[] arguments, Boolean
construct,
Boolean brackets, VsaEngine engine)
at JScript 0.Global Code()
at JScript Main.Main(String[] )

?? Maybe: the decimal value is internally converted into a localized
string value? Before parameter substitution.
*/

import System;
import System.Data;
import System.Data.OleDb;

var adox = new ActiveXObject("ADOX.Catalog");
adox.Create("Provider='Microsoft.Jet.OLEDB.4.0';Data
Source='test.mdb';");

var con = new OleDbConnection("Provider='Microsoft.Jet.OLEDB.4.0';\
Data Source='test.mdb'");
con.Open();

var cmd = con.CreateCommand();
cmd.CommandText = "CREATE TABLE foo (bar VARCHAR(10) NOT NULL,\
pi DECIMAL(5,4) NULL, CONSTRAINT PK_foo PRIMARY KEY (bar))";
cmd.ExecuteNonQuery();

// always works

var cmd = con.CreateCommand();
cmd.CommandText = "INSERT INTO foo (bar, pi) VALUES ('this', 1.0101)";
cmd.ExecuteNonQuery();

// fails under dutch regional settings

var cmd = con.CreateCommand();
cmd.CommandText = "INSERT INTO foo (bar, pi) VALUES (?, ?)";
cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("bar",
OleDbType.VarWChar, 10, "bar"));
cmd.Parameters.Add(new OleDbParameter("pi",
OleDbType.Decimal, 0, ParameterDirection.Input, false, (Byte)(5),
(Byte)(3), "pi", DataRowVersion.Current, null));

cmd.Parameters["bar"].Value = 'hello';
cmd.Parameters["pi"].Value = 3.1415;
cmd.ExecuteNonQuery();

print('finished...');
 
M

Miha Markic

Hi Saner,

You should really use parametrised stataments.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Sander said:
Hello,

I think i am having the same problem here. This JScript source should
pinpoint the problem when Windows uses the "Dutch" regional settings.
Is this problem acknowledged and is there a workaround other then
using the Double floating point type or using a full MSDE
installation? We are building a product based upon .NET and the Jet
engine for the Dutch market. This problem seriously hinders our
program to work with decimal fields.

Thank you for your time!
Best regards,
Sander

---- Example sourcecode:

/* JScript - test.js
compile: jsc test.js
platforms tested: Win2K with Jet 4.00.8015.0 (SP 8) and WinXP

Works fine with "English (United States)" regional settings (decimal
seperator: .), however fails with "Dutch (Netherlands)" regional
settings (decimal seperator: ,)

THIS ALSO FAILS WITH VS.NET GENERATED C# DataAdapters

Unhandled Exception: System.Data.OleDb.OleDbException: The decimal
field's preci
sion is too small to accept the numeric you attempted to add.
at Microsoft.JScript.JSMethodInfo.Invoke(Object obj, BindingFlags
options, Bi
nder binder, Object[] parameters, CultureInfo culture)
at Microsoft.JScript.LateBinding.CallOneOfTheMembers(MemberInfo[]
members, Ob
ject[] arguments, Boolean construct, Object thisob, Binder binder,
CultureInfo c
ulture, String[] namedParameters, VsaEngine engine)
at Microsoft.JScript.LateBinding.Call(Binder binder, Object[]
arguments, Para
meterModifier[] modifiers, CultureInfo culture, String[]
namedParameters, Boolea
n construct, Boolean brackets, VsaEngine engine)
at Microsoft.JScript.LateBinding.Call(Object[] arguments, Boolean
construct,
Boolean brackets, VsaEngine engine)
at JScript 0.Global Code()
at JScript Main.Main(String[] )

?? Maybe: the decimal value is internally converted into a localized
string value? Before parameter substitution.
*/

import System;
import System.Data;
import System.Data.OleDb;

var adox = new ActiveXObject("ADOX.Catalog");
adox.Create("Provider='Microsoft.Jet.OLEDB.4.0';Data
Source='test.mdb';");

var con = new OleDbConnection("Provider='Microsoft.Jet.OLEDB.4.0';\
Data Source='test.mdb'");
con.Open();

var cmd = con.CreateCommand();
cmd.CommandText = "CREATE TABLE foo (bar VARCHAR(10) NOT NULL,\
pi DECIMAL(5,4) NULL, CONSTRAINT PK_foo PRIMARY KEY (bar))";
cmd.ExecuteNonQuery();

// always works

var cmd = con.CreateCommand();
cmd.CommandText = "INSERT INTO foo (bar, pi) VALUES ('this', 1.0101)";
cmd.ExecuteNonQuery();

// fails under dutch regional settings

var cmd = con.CreateCommand();
cmd.CommandText = "INSERT INTO foo (bar, pi) VALUES (?, ?)";
cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("bar",
OleDbType.VarWChar, 10, "bar"));
cmd.Parameters.Add(new OleDbParameter("pi",
OleDbType.Decimal, 0, ParameterDirection.Input, false, (Byte)(5),
(Byte)(3), "pi", DataRowVersion.Current, null));

cmd.Parameters["bar"].Value = 'hello';
cmd.Parameters["pi"].Value = 3.1415;
cmd.ExecuteNonQuery();

print('finished...');
 
M

Miha Markic

Duh, yes, you are right - I've read too fast.

Yes, few threads below I examined the same problem. I think that jet =
driver is using wrong method (my wild guess is that it uses some sort of
string conversion, ouch - i think it is an automation problem).

I don't know of any other workaround and I doubt that there is a nice = one.


--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Sander said:
Hello,

I think i am having the same problem here. This JScript source should
pinpoint the problem when Windows uses the "Dutch" regional settings.
Is this problem acknowledged and is there a workaround other then
using the Double floating point type or using a full MSDE
installation? We are building a product based upon .NET and the Jet
engine for the Dutch market. This problem seriously hinders our
program to work with decimal fields.

Thank you for your time!
Best regards,
Sander

---- Example sourcecode:

/* JScript - test.js
compile: jsc test.js
platforms tested: Win2K with Jet 4.00.8015.0 (SP 8) and WinXP

Works fine with "English (United States)" regional settings (decimal
seperator: .), however fails with "Dutch (Netherlands)" regional
settings (decimal seperator: ,)

THIS ALSO FAILS WITH VS.NET GENERATED C# DataAdapters

Unhandled Exception: System.Data.OleDb.OleDbException: The decimal
field's preci
sion is too small to accept the numeric you attempted to add.
at Microsoft.JScript.JSMethodInfo.Invoke(Object obj, BindingFlags
options, Bi
nder binder, Object[] parameters, CultureInfo culture)
at Microsoft.JScript.LateBinding.CallOneOfTheMembers(MemberInfo[]
members, Ob
ject[] arguments, Boolean construct, Object thisob, Binder binder,
CultureInfo c
ulture, String[] namedParameters, VsaEngine engine)
at Microsoft.JScript.LateBinding.Call(Binder binder, Object[]
arguments, Para
meterModifier[] modifiers, CultureInfo culture, String[]
namedParameters, Boolea
n construct, Boolean brackets, VsaEngine engine)
at Microsoft.JScript.LateBinding.Call(Object[] arguments, Boolean
construct,
Boolean brackets, VsaEngine engine)
at JScript 0.Global Code()
at JScript Main.Main(String[] )

?? Maybe: the decimal value is internally converted into a localized
string value? Before parameter substitution.
*/

import System;
import System.Data;
import System.Data.OleDb;

var adox = new ActiveXObject("ADOX.Catalog");
adox.Create("Provider='Microsoft.Jet.OLEDB.4.0';Data
Source='test.mdb';");

var con = new OleDbConnection("Provider='Microsoft.Jet.OLEDB.4.0';\
Data Source='test.mdb'");
con.Open();

var cmd = con.CreateCommand();
cmd.CommandText = "CREATE TABLE foo (bar VARCHAR(10) NOT NULL,\
pi DECIMAL(5,4) NULL, CONSTRAINT PK_foo PRIMARY KEY (bar))";
cmd.ExecuteNonQuery();

// always works

var cmd = con.CreateCommand();
cmd.CommandText = "INSERT INTO foo (bar, pi) VALUES ('this', 1.0101)";
cmd.ExecuteNonQuery();

// fails under dutch regional settings

var cmd = con.CreateCommand();
cmd.CommandText = "INSERT INTO foo (bar, pi) VALUES (?, ?)";
cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("bar",
OleDbType.VarWChar, 10, "bar"));
cmd.Parameters.Add(new OleDbParameter("pi",
OleDbType.Decimal, 0, ParameterDirection.Input, false, (Byte)(5),
(Byte)(3), "pi", DataRowVersion.Current, null));

cmd.Parameters["bar"].Value = 'hello';
cmd.Parameters["pi"].Value = 3.1415;
cmd.ExecuteNonQuery();

print('finished...');
 

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

Similar Threads


Top