Unable to connect to AS400 in C# RRS feed

  • Question

  • I am trying to connect to an AS400 database from C# code and cannot find what I am doing wrong.
    This is the error that I get (thrown by the conn.Open()):
    "Non-NULL controlling IUnknown was specified, and either the requested interface was not IUnknown, or the provider does not support COM aggregation."

    Here is the body of my code:
    String connectionString = "Provider=IBMDA400;Data Source=myAS400;User ID=myUser;Password=myPassword;";
    System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connectionString);
    conn.Open();   <--- this is where it throws an Exception.

    Here is what I don't understand -- I am able to create a connection to the AS400 through the 'Server Explorer' with these settings:
    Data Source: .NET Framework Data Provider for OLE DB
    OLE DB Provider: IBM AS400 OLE DB Provider
    Server: myAS400
    User: myUser
    Pass: myPassword

    Any ideas what my problem is - and how I might be able to create that same connection within my C# code.

    Friday, August 3, 2007 6:09 PM

All replies

  • Friday, August 3, 2007 7:17 PM
  • That tutorial didn't seem to address my issue.

    I tried using the "Provider=IBMDADB2;" discussed in the tutorial -- but Visual Studio doesn't recognize that as a valid provider (Error: "The 'IBMDADB2' provider is not registered on the local machine.")

    In the Server Explorer I am connecting to my AS400 by using the "IBM AS400 OLE DB Provider" which generates this part of the Connection String: "PROVIDER=IBMDA400;" Visual Studio recognizes that provider -- but generates the error mentioned in my original post.

    Friday, August 3, 2007 8:24 PM