Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2008
    Posts
    2

    Unanswered: Connection issues using vbs

    I use the following code to connect to an Informix db:

    Dim oDb
    Dim oRecSet
    Dim oDbError
    Dim sDbConnString
    Dim sSql
    Dim DSN

    sSql = "Select first 1000 nds_no from asn where actual_po_no is null"

    ' Connect to db
    Set oDb = CreateObject("ADODB.connection")
    If oDb.state = 1 Then
    WScript.Echo "Object State: " & oDb.state
    oDb.close
    End If

    ' Set DB connection string
    sDbConnString = "DRIVER=IBM INFORMIX ODBC DRIVER" & ";" & "UID=" & "XXXX" & ";" & _
    "PWD=" & "XXXX" & ";" & "PRO=onsoctcp;" & "SRVR=" & "crme05_tcp" & ";" & _
    "SERV=" & "crme05_tcp" & ";" & "HOST=dundev01;" & "DB=" & "fss"

    WScript.Echo "sDbConnString: " & sDbConnString
    oDb.open sDbConnString

    If oDb.Errors.Count > 0 Then
    For Each oDbError In oDb.Errors
    'If oDbError.Number <> 0 Then
    WScript.Echo "Native Error: " & oDbError.NativeError
    WScript.Echo "Description: " & oDbError.Description & vbNewLine
    WScript.Echo "SQLState: " & oDbError.SQLState & vbNewLine
    WScript.Echo "Source: " & oDbError.Source & vbNewLine
    'End If
    Next
    oDb.errors.Clear
    End If

    ' Query the database
    Set oRecSet = CreateObject("ADODB.RECORDSET")
    oRecSet.open sSql,oDb,3,3
    WScript.Echo "oRecSet.RecordCount: " & oRecSet.RecordCount

    When run I'm getting returned the following error:

    Description: [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr

    The above code worked fine up until last friday (26/09), there hasnt been any changes applied either.

    What we have been unable to establish though is why the connection details work if we view the db via Excel but not via the vbs script.

    Any help would be greatly appreciated.

    Regards

    David

  2. #2
    Join Date
    Sep 2008
    Posts
    2
    Ignore the above, after a bit of digging connection is actually established.

    What we didnt anticipate was that for whatever reason the cursortype is now only being returned as '0'.

    This meant that we now have to use a different method other than .recordcount.

Posting Permissions

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