If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Connection issues using vbs

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-30-08, 06:37
Davidel Davidel is offline
Registered User
 
Join Date: Sep 2008
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 09-30-08, 10:27
Davidel Davidel is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On