Changing NLS_LANGUAGE Oracle Parameter via C# in ASP.NET

I am working on ASP.NET web application to retrieve a data from oracle database via C# that has been retrieved successfully,

ِAbout a week ago,I found out the format of retrieving data has been changed, and the web application raises unexpected behavior although I didn’t change any thing in my code.

Cause : 

This might occurred if NLS_LANGUAGE Oracle Parameter has been changed from AMERICAN to ARABIC.

1

2

Solution :

To overcome this issue you should set NLS_LANGUAGE  in code manually by following the bit steps below :

Open Visual Studio > Open existing  ASP.NET Solution > Make sure that Oracle.DataAccess.Client reference has been added.

Using Oracle.DataAccess.Client ;

After opening the connection to database, Add the following bold code.

Oracle.DataAccess.Client.OracleConnection mConnection 
= new Oracle.DataAccess.Client.OracleConnection(OracleConn);
mConnection.Open();
var si = mConnection.GetSessionInfo();
si.Language = "AMERICAN"; // for English or ARABIC for Arabic
mConnection.SetSessionInfo(si);

The previous code should allow you to set a NLS_LANGUAGE based on your requirement.

Enjoy 🙂

See also

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s