Using ADO.Net on machines with comma for decimal point

  • Thread starter Thread starter Heinz Kiosk
  • Start date Start date
H

Heinz Kiosk

Hi,

The following code works fine on a UK/US machine but fails on a French
machine. I've isolated the failure to the "," decimal point on French
machines by using customise on Regional Settings in Control Panel.

I've found other references on the web to this problem but the responses
have been a mixture of, "I don't believe that such a basic problem could
exist in the implementation of decimals in ADO.NET" and plain
misunderstanding of the problem. I haven't been able to find any
solutions other than getting rid of "," for decimal point, which some
continental europeans won't agree to do.

OleDbConnection conn = new OleDbConnection(SomeConnectionString);
conn.Open();

// The exact mechanism for creating the adapter select and
// update commands seems to be irrelevant
// Likewise this failure occurs with VS2005 wizard-generated
// adapters and typed datasets too.
OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from
sometable", conn);
OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
adapter.UpdateCommand = builder.GetUpdateCommand();

DataTable t = new DataTable();
t.Columns.Add(new DataColumn("Payroll", typeof(String)));
t.Columns.Add(new DataColumn("HoursPerPeriod",
typeof(Decimal))); // the decimal column is the problem
adapter.Fill(t);
t.Rows[0]["HoursPerPeriod"] =
Convert.ToDecimal(t.Rows[0]["HoursPerPeriod"]) + 1;
// The next line throws the exception
// "Data Type Mismatch in Criteria Expression"
// on machines with ',' for decimal point in regional settings
// but UK and US machines work fine...
adapter.Update(t);

Thanks in advance for any light shed on this problem.

Kind Regards

Tom
 
I am using the Jet 4.0 provider.

I removed the explicit connection string from my code sample in the
interests of "clarity". Evidently I made the issue less clear by doing
that...

Kind Regards

Tom
 
Back
Top