1
votes

I am trying to figure out how to connect to an IBM informix database. I have been doing some research and have found some threads from 5 years ago but those examples are not working.

I have installed the latest SDK from IBM for informix.

I have included the IBM.Data.Informix.dll to my references in my project.

I have included the using IBM.Data.Informix;

I am just adding a button and on click testing the conenction. I always get this debug error "SQL0035N The file "C:\Users\Adam\documents\visual studio 2010\Projects\test\test\msg\en_US\db2nmp.xml" cannot be opened."

This file does not exist and I dont see it anywhere in the Program Files (x86)\IBM Informix Client SDK directory.

My On click code is

    private void button1_Click(object sender, EventArgs e)
    {
        const string HOST = "192.168.OBFUSCATED";
        const string SERVICENUM = "1525"; //Port?
        const string SERVER = "serverOBFUSCATED";
        const string DATABASE = "dbOBFUSCATEDy";
        const string USER = "myusername";
        const string PASSWORD = "mypassword";

        string ConnectionString = "Host=" + HOST + "; " +
         "Service=" + SERVICENUM + "; " +
         "Server=" + SERVER + "; " +
         "Database=" + DATABASE + "; " +
         "User Id=" + USER + "; " +
         "Password=" + PASSWORD + "; ";

        IfxConnection conn = new IfxConnection();
        conn.ConnectionString = ConnectionString;
        try
        {
            conn.Open();
            MessageBox.Show("Made connection!");
        }
        catch (IfxException ex)
        {
            MessageBox.Show("Problem with connection attempt: " + ex.Message);
        }
    }

Anyone know what I am doing wrong or the current best way to connect to informix database?

Thanks in advance.

2

2 Answers

0
votes

Check your version of informix. What you need is a connector compatible with your version of informix database installed.

check this: http://www.ibm.com/developerworks/data/library/techarticle/dm-1007dsnetids/index.html

0
votes

I was experiencing the same error, try to form your string with the following format:

string ConnectionString = "Server=" + HOST + ":" + SERVICENUM + "; " +
     "Database=" + SERVER + "\" + DATABASE + "; " +
     "User Id=" + USER + "; " +
     "Password=" + PASSWORD + "; ";

The result, using the values from your example, should be:

"Server=192.168.OBFUSCATED:1525;Database=serverOBFUSCATED\dbOBFUSCATEDy;User ID=myusername;Password=mypassword;"