开发者

How do I connect to Informix with .NET?

开发者 https://www.devze.com 2023-01-06 00:12 出处:网络
Background Information: Visual Studio 2010 (.NET Framework 4.0) Informix Server 7.31 Informix ClientSDK 3.50 TC7 (Windows 32-bit) was installed as well.

Background Information:

  • Visual Studio 2010 (.NET Framework 4.0)
  • Informix Server 7.31
  • Informix ClientSDK 3.50 TC7 (Windows 32-bit) was installed as well.

I have tried multiple ways suggested online to connect to the Informix server, but all of them do not work for me for whatever reason. I have looked at articles such as Connect Informix with ADO.Net and I have used ConnectionStrings.com to generate a connection string.

When I go to Visual Studio I do the following:

  1. Server Explorer
  2. Right-click on Data Connections > Add Connection...
  3. Microsoft ODBC Data Source | .NET Framework Data Provider for ODBC
  4. Use connection string (copied/pasted using the ConnectionString website).
  5. Test Connection

RESULT: ERROR [IM002][Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.

  1. Server Explorer
  2. Right-click on Data Connections > Add Connection...
  3. Other | .NET Framework Data Provider for ODBC
  4. Use connection string (copied/pasted using the ConnectionString website).
  5. Test Connection

RESULT: ERROR [IM002][Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.

  1. Server Explorer
  2. Right-click on Data Connections > Add Connection...
  3. Other | .NET Framework Data Provider for OLE DB
  4. OLE DB Provider: IBM Informix OLE DB Provider
  5. Data Links...

RESULT: The specified procedure could not be found. (Exception from HRESULT: 0x8007007F)

Beyond that I wasn't sure what to really fill in there...

Oh, and I even tried to use the sample code provided in the first article, substituting in my connection information:

  • HOST: The IP of the server
  • SERVICENUM: The Port Number
  • SERVER: The servers name
  • DATABASE: The database I'm working on
  • USER: user id
  • PASS: password

Sample code I downloaded/altered:

using System;
using IBM.Data.Informix;

names开发者_StackOverflow中文版pace IfxAdoPres.Basics {
    public class BasicConnection {
        const string HOST = "192.168.OBFUSCATED";
        const string SERVICENUM = "5000";
        const string SERVER = "myServer";
        const string DATABASE = "myDatabase";
        const string USER = "myUserID";
        const string PASSWORD = "myPassword";

        public IfxConnection conn = new IfxConnection();
        public BasicConnection() {}

        public void MakeConnection() {
            string ConnectionString = "Host = " + HOST + "; " +
                "Service=" + SERVICENUM + "; " +
                "Server=" + SERVER + "; " +
                "Database=" + DATABASE + "; " +
                "User Id=" + USER + "; " +
                "Password=" + PASSWORD + "; ";

            conn.ConnectionString = ConnectionString;
        }

        public void CloseConnection() {
            conn.Close();
        }
    }
}

I get an error on the line conn.ConnectionString = ConnectionString; The exception states "Invalid argument" with no InnerException (basically very unhelpful). The callstack is:

  • Basics.exe!IfxAdoPres.Basics.BasicConnection.MakeConnection()
  • Basics.exe!IfxAdoPres.Basics.Test.Main(string[] args = {string[0]})
  • [External Code]

I am stuck and have no idea what to do... :-/


Well, I went back to the article: http://www.ibm.com/developerworks/data/library/techarticle/dm-0510durity/

After uninstalling everything and starting out fresh, the demo code seemed to work after installing the IBM Informix Client SDK 3.5 and using Setnet32 to configure my settings.

I must've had something corrupt since I had a couple of different of versions of the Informix Driver installed initially.

0

精彩评论

暂无评论...
验证码 换一张
取 消