Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2014

    Unanswered: Automation error message when trying to connect to AS400 from excel vba

    Hi I have the following code in vba excel to connect to as400 server.
    However it gives...
    Sub transfer()

    Dim varState As String

    Set CS = CreateObject("ADODB.Connection")
    Set RS = CreateObject("ADODB.Recordset")
    Const adOpenStatic = 3
    Const adLockOptimistic = 3
    Const adUseClient = 3
    'Retrieve values from Cells on the sheet to use as selections in the query below
    varState = ActiveSheet.Range("C2").Value
    varFrom_Date = ActiveSheet.Range("B3").Value
    varTo_Date = ActiveSheet.Range("B4").Value

    'ISeries connection String

    ConnectString = "Driver={ISeries Access ODBC Driver};System=****8;Library=****;UID = ***;PASSWORD =***;QueryTimeout=0?"
    CS.Open (ConnectString)

    SqlString = "SQL STMT"
    RS.Open SqlString, CS
    reccount = RS.RecordCount
    MsgBox reccount

    End Sub

    however im getting a an automation error message

  2. #2
    Join Date
    Apr 2012
    Provided Answers: 17
    What is the exact message you get ?
    Can you successfully connect to the database from this workstation with the same userid/password without using vba ?

Posting Permissions

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