Results 1 to 12 of 12

Thread: odbc - ADO to connect to as/400

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71

    odbc - ADO to connect to as/400

    Could someone help me (code) to connect to an as/400 database using ado and an odbc driver.
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Check out This MSKB Article

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71
    thanks but I have looked there and I am still confused about the connection string.
    any help???
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

  4. #4
    Lively Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    71

    AS400 connection

    Dim rsAS400 As ADODB.Recordset
    Dim cnAS400 As ADODB.Connection


    Set cnAS400 = New ADODB.Connection
    Set rsAS400 = New ADODB.Recordset


    'Live connection
    cnAS400.ConnectionString = "DSN=AS400;DRIVER={client Access ODBC data source};SERVER=servername;DATABASE=libraryname;UID=userid;Passwowd=kmu;"


    cnAS400.Open
    Set rsAS400.ActiveConnection = cnAS400
    rsAS400.LockType = adLockBatchOptimistic
    rsAS400.CursorType = adOpenKeyset

    In addition, you must set up a ODBC connection. Connection name is AS400

  5. #5
    Member
    Join Date
    Nov 2000
    Posts
    43
    Here is a connection string that works for me.

    Set dbMyODBCDB = DBEngine(0).OpenDatabase _
    ("", False, False, "ODBC;DSN=AS400 ODBC;;TABLE=XXX@@XXXX.XXXXX;UID=;PWD=") 'Publishers")

    tHE dsN WILL BE WHATEVER YOU NAMED IT THE xxxx@@@xxxx.xxxxx IS THE NAME OF THE DEFAULT as400 LIBRARIES AS DEFINED BY THE SYSTEM OPERATOR./

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71
    hey packman,

    you said that I must set up a ODBC connection.. how is this done.. I know that the driver is the name that I give the odbc within the client access... but I am confused about the DSN.
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

  7. #7
    Lively Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    71

    ODBC connection

    -From the Windows atart menu
    -Go to settings
    -then go to control panel
    -ODBC datasources and open it
    -go to System DSN tab
    -click the add button
    -choose the driver: Client Access ODBC
    -go to the General Tab and DSN should be whatever your connection DSN is (as400)
    -Under the Server Tab: type in the default Library.

    There are other setting. However, normally I only have to modify the afformentioned.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71
    so the DSn is the data source ... t And i know this may seem stupid but the area in the connection string.. for Driver.. what is this suppose to be...
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

  9. #9
    Lively Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    71

    Driver

    Thats the name of the Driver that you should have loaded on your PC. When you set up the ODBC connection it will give you a list of drivers to choose from. To ref that driver in code:
    Driver = {client Access ODBC data source}

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71
    i have done the code (packman) and I received this error..


    [IBM][Client Access ODBC Driver (32 bit)][DB2/400] Communication Link Failure, Comm RC=0x5

    here is my code

    Dim connAS400 As ADODB.Connection
    Dim rsAS400 As ADODB.Recordset

    Set connAS400 = New ADODB.Connection
    Set rsAS400 = New ADODB.Recordset
    connAS400.ConnectionString = "DSN=AS400;DRIVER={client access ODBC data source};SERVER=todc88;database=altdelca.apt171la;UID=@@@@;PWD=@@@@;"
    connAS400.Open
    Set rsAS400.ActiveConnection = connAS400
    rsAS400.LockType = adLockBatchOptimistic
    rsAS400.CursorType = adOpenKeyset
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

  11. #11
    Lively Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    71

    Database name

    In the AS400 world the Database name is referred to as the Library. Do you have a library named "altdelca.apt171la".
    Also, is that actually your pwd and userid?

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71
    yes there is a library named that and the passwrod and userid are in the program.. i did not enter them here for work security purposes.

    but isthe part about the driver suppose to be just like that
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width