Set NLS_LANG for oracle managed data access

Alex McMahon picture Alex McMahon · Jun 19, 2014 · Viewed 12.8k times · Source

I have a winforms c# application using Oracle 12c through oracle.manageddataaccess (via NHibernate 4.0), The oracle database is on another machine on customer site we've had issues with character set conversion due to NLS_LANG differences between the oracle database and the client machine. There is no Oracle client installed on the client machine (just using Managed driver).

We've found that you can specify the client NLS_LANG using an environment variable.

My question is: Are there any other ways to specify the NLS_LANG setting when using the new Managed Data Access in Oracle?

Answer

TonyP picture TonyP · Oct 12, 2014

I am using the OracleGlobalization to set Date format as follows. This might give you a clue..

 conn = new OracleConnection(connectionString);
        conn.Open();
        OracleGlobalization info = conn.GetSessionInfo();
        info.DateFormat = "YYYY-MM-DD";
        conn.SetSessionInfo(info);