Oracle – Effects of changing NLS_LANG setting in the registry for Oracle Client

odp.netora-12705oracleoracleclientregistry

We are in the process of moving from the .NET Microsoft oracle driver to the ODP.NET driver.

One of the problems we have had is this error:

ORA-12705: Cannot access NLS data files or invalid environment specified

We were able to stop the error by modifying the registry and changing the setting (see this question)

In our case we changed

HKEY_LOCAL_MACHINE - SOFTWARE - ORACLE - NLS_LANG

which was set to NA

to be the same as

HKEY_LOCAL_MACHINE - SOFTWARE - ORACLE - HOME0 - NLS_LANG

which was set correctly

My question is why would there be different NLS_LANG settings in the registry, and might there be any knock on effects of changing this value?


Update:
I've just found in the Oracle NLS FAQ the following

For Oracle version 7:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE

For Oracle Database versions 8, 8i and
9i:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOMEx\

where "x" is the unique number
identifying the Oracle home.

HOME0 is the first installation

For Oracle Database 10g:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_<oracle_home_name>

There you have an entry with name
NLS_LANG

OK, so there are different registry settings for different versions…

Note:

Some people are confused by finding a
NLS_LANG set to "NA" in
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
when no version 7 was installed. This
is used for backwards compatibility,
and can be ignored.

I have Oracle 9i, so now I'm even more confused – why is the ODP.NET dll looking at the Oracle 7 registry setting?

Best Answer

I had a similar problem with the;

ORA-12705: Cannot access NLS data files or invalid environment specified

The ODP.NET dll's or instant client were reading the registry;

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\NLS_LANG=NA

The value NA caused the error.

This was because I already had a client installation but I wanted to use the oracle instant client via network drive for the a VB.NET app with ODP.NET.

My simple fix in my vb.net solution was for example to adjust the environment for the application via:

Environment.SetEnvironmentVariable("NLS_LANG", 
                    "AMERICAN_AMERICA.WE8MSWIN1252", 
                    EnvironmentVariableTarget.Process)

nb. The Oracle "NLS FAQ" link is no longer valid (2012)

Related Topic