0
votes

I am having below piece of code where i try to connect to IBM's Informix database.

  public void MakeConnection()
        {
            string ConnectionString = "Database=databasename;Host=ipaddress;Server=servername;Service=port;Protocol = olsoctcp; UID = userid; Password = password;";
            IfxConnection conn = new IfxConnection();
            conn.ConnectionString = ConnectionString;
            try
            {
                conn.Open();
            }
            catch (IfxException ex)
            {
                Console.WriteLine(ex.ToString());
            }    
            Console.ReadLine();
        }

Getting below error on opening a connection.

ERROR [HY000] [Informix .NET provider][Informix]Database locale information mismatch.

When i try connecting using windows ODBC Data sources application, by creating a new user data source under User DSN and providing all necessary values under each section of Informix ODBC driver setup, i am able to connect successfully.

All i understand is that the client application's and database's Database Locale value should be same for proper query execution, and i have tried using en_US.57372 and en_US.UTF8 DB Locale while configuring in user DSN's which worked pretty well. I am posting here a image for better understanding.

ODBC Driver Setup for Informix and connectivity test

Appreciate if anyone can help me in knowing where i can find DB Locale configured for in an Informix database and also in detail on what actually causes for this error.

1
If you can use connect to and query the database, you can find the locale with the following query: SELECT * FROM systables WHERE tabid IN ( 90, 91 );. After that you can add the locale information to your connection string ( check the online Informix .net documentation ).Luís Marques
@LuísMarques thanks for help;ashmabi

1 Answers

1
votes

Finally able to connect to database from test application!. Okay here we go,

Step 1: First we need to find what Database locale that database allows us to use? so following @Luis Marques way as he mentioned in comment section, found that Database Locale used is en_US.57372, also en_US.UTF8 is supported.

Step 2: By default, connection object's client locale and database locale property values will be whatever default value was set when Informix ODBC driver was installed.

Slightly modified my test app code as below,

   public void MakeConnection()
        {
            string ConnectionString = "Database=databasename;Host=ipaddress;Server=servername;Service=port;Protocol = olsoctcp; UID = userid; Password = password;";
            IfxConnection conn = new IfxConnection();
            conn.ConnectionString = ConnectionString;
            conn.ClientLocale = "en_US.UTF8";
            conn.DatabaseLocale = "en_US.UTF8";
            try
            {
                conn.Open();
            }
            catch (IfxException ex)
            {
                Console.WriteLine(ex.ToString());
            }    
            Console.ReadLine();
        }

So manually assigning client and database locale values for connection object with what we have got in step 1 solved the issue.