Brian

Brian

  • NA
  • 3
  • 0

Unable to connect to AS400 in C#

Aug 3 2007 3:27 PM
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.
conn.Close();

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.

Thanks!

Answers (1)