Hello,
I have a program for executing querys about Oracle Database. My program used to use ODP.NET unmanaged driver and I need to configure dates format before execute the query.
I did it this way with ODP.NET Unmanaged:
OracleGlobalization og = OracleGlobalization.GetClientInfo();
og.DateFormat = "DD/MM/YYYY hh24:mi:ss";
OracleGlobalization.SetThreadInfo(og);
OracleCommand cmd = new OracleCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.CommandText = “select…”;
OracleDataAdapter datAdapt = new OracleDataAdapter(cmd);
//I need to use ODP.NET types instead of .NET types
datAdapt.ReturnProviderSpecificTypes = true;
DataSet ds = new DataSet();
datAdapt.Fill(ds);
This code works fine until I change to ODP.NET managed driver. I couldn't use Thread and client info for globalization because it's not supported in ODP.NET managed so I though to use session info instead. Then, when dataset contains any column of type OracleDate, it shows like American (MM/DD/YYYY) instead of Spanish (DD/MM/YYYY). It seems that Session info doesn't apply.
https://docs.oracle.com/cd/E56485_01/win.121/e55744/intro004.htm
New code:
OracleGlobalization info = con.GetSessionInfo();
info.DateFormat = "DD/MM/YYYY hh24:mi:ss";
info.TimeStampFormat = "DD/MM/YYYY hh24:mi:ss";
info.DateLanguage = "SPANISH";
con.SetSessionInfo(info);
How could I set the language for dates with odp.net Managed driver?
I have noticed that if I set datAdapt.ReturnProviderSpecificTypes to false (using .NET types instead of ODP.Net types) the .NET object “System.Datetime” shows dates properly, but with other types like “System.string” instead of OracleCLOB (ODP.NET type) I'll lost data because of System.String can store less characters.
What is the solution for ODP.NET managed driver?
I use Oracle.ManageddataAccess 21.13.0 (from nuget repository)
Thank you very much!