Changing NLS_LANGUAGE Oracle Parameter via C# in ASP.NET

In this article, I will explain

How to change “NLS_LANGUAGE” Oracle Parameter via C# in ASP.NET

Changing NLS_LANGUAGE Oracle Parameter via C# in ASP.NET


Scenario

I am working on ASP.NET web application to retrieve a data from oracle database via C# that has been retrieved successfully, Suddenly, I found out the format of the retrieving data has been changed, and the web application raises unexpected behavior although I didn’t change anything in my code.


Cause

This issue might occur in case, the NLS_LANGUAGE Oracle Parameter has been changed from AMERICAN to ARABIC.

Change NLS_LANGUAGE Oracle Parameter

2


Solution

Instead of depending on the NLS Parameter setting in Oracle, you should set NLS_LANGUAGE  in the code by doing the following:

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

Using Oracle.DataAccess.Client;

  • In your code, specifically, after the connection database open statement,

Oracle.DataAccess.Client.OracleConnection mConnection = new Oracle.DataAccess.Client.OracleConnection(OracleConn);

mConnection.Open();

  • Add the below code.

var si = mConnection.GetSessionInfo();
si.Language = "AMERICAN"; // for English or ARABIC for Arabic
mConnection.SetSessionInfo(si);

  • Build and run your application that should be now working properly.

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s