Link to home
Create AccountLog in
Avatar of victoriaharry
victoriaharry

asked on

DB2 Connection error SQL30081N

HI,

I'm looking for a possible cause for the attached error which happens occasionally when calling the function below. It doesn't happen everytime which is making it hard to troubleshoot
I have a VBS application calling the function which makes a call to a DB2 database and runs the requested sql. It could execute without error for a given sql then fail the next time the same sql is passed

Function GetDatabaseRecordSet(sql,dataSource,userID,password)

Dim arrRecordSet
Set myConnection = CreateObject("ADODB.Connection")
Set myRecordSet = CreateObject("ADODB.RecordSet")

ConnectionString = 'Provider=MSDASQL.1;Persist Security Info=False;UserID=" & userID & ";Password=" & password & ";Data Source =" & dataSource

myConnection.Open ConnectionString
myRecordSet.CursorType = 1

myRecordSet.Open SQL,myConnection

myRecordSet.MoveFirst

arrRecordSet = myRecordSet.GetRows()

GetDatabaseRecordSet = arrRecordSet

myRecordSet.Close
myConnection.Close

End Function
connection-error.bmp
ASKER CERTIFIED SOLUTION
Avatar of pritamdutt
pritamdutt
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of victoriaharry
victoriaharry

ASKER

I will try them but it actually works most of the time so the connection string appears to be valid

When I look at the Data Source Administrator the driver for the data source I'm using is IBM DB2 ODBC DRIVER
If it used to work earlier, please check to see if you are able to ping your server and the Data source Test is passing through Data Source Administrator.


However, I would still recommend to use OLEDB independent of ODBC.

Regards,
Hi,

I changed it to Provider=IBMDADB2;Data Source=AAAA;User Id=BBBB;Password=CCCC; and it seems to be working ok for the moment.
Does this seem more reliable way to connect to the DB2 database?
It is always best to use Native Drivers for any Database Connection.

Regards,