how to migrate doubles and dates from System.Data.OracleClient to ODP.NET?

712 Views Asked by At

This migration seem to be really challenging. What i'm trying to do now is to execute simple queries to a oracle db table:

OBJECTID NOT NULL NUMBER,
DOUBLEVALUE NOT NULL FLOAT(126),
MODTIME DATE

when I use System.Data.OracleClient I can INSERT parametrized queries where parameter values are:

123, 
"123.123", 
DateTime.Now.ToString(). 

and DbParameter.DbTypes are:

DbType.Int32,
DbType.Double,
DbType.Date

If I use Oracle.DataAccess.Client this is not working:

For DOUBLEVALUE I get exception because in my system Convert.ToDouble (which is called by OracleParameter.PreBind_Double) expects that I use comma ("123,123"). I do not want to change all the values in all programs and files. Also OleDb can handle this without problems.

For MODTIME I get "ORA-01830: date format picture ends before converting entire input string." This works if I change the value to DateTime.Now.ToShortDateString(). Possibly also if I change the parameter type. Also this OleDb can handle.

It seems ridiculous that Oracle.DataAccess.Client cannot handle these really basic situations which System.Data.OracleClient and System.Data.OleDb have no problems. Any recommendations?

Thanks & Best regards -Matti

1

There are 1 best solutions below

4
On BEST ANSWER

Your problem with the comma comes from the default culture used by your processing thread. Try forcing en-US culture:

Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");