Dynamically connect to AS400 DB2 database through ODBC

  • Dear all:

    I need to download data from AS400 to the SQL server. The ODBC I have created is only for one server and one library. However I need to set the connection dynamically because the server name and library name can get changed later. From .Net Providers\Odbc Data Provider connection manager, I can only specify the DSN name, user name/password but not other connection information. I don't think creating a list of DSNs on the server is a good idea. Can anybody tell me if I can create the ODBC connection dynamically or use other way to access AS400 files. Many thanks!

  • Not sure if this will work, but you can set the whole connection string to the ODBC in one go, so you could build it dynamically with dsn name, username, password, etc. or pull it from a database or config file.

    I don't know (even if this does work) how the username and password information would be transmitted across the network. Could well be sent in plain text.

    Tom

    Life: it twists and turns like a twisty turny thing

  • How about setting up the connection information on the SQL side static to point to a reference object in DB2 on your 400. Then, as the actual library in DB2 changes, simply change the reference object in DB2.

  • Thank you guys for the response.

    I am trying to use this connection string which I have got from a colleague, haven't tried it successfully. But I was told it should work

    oAS400Conn.ConnectionString = "Driver={Client Access ODBC Driver (32-bit)};" +

    "System=" + objCountryDetails.ServerName + ";Uid=" + objCountryDetails.UserName

    + ";Pwd=" + objCountryDetails.Password + ";DBQ=" + strLibName;

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply