View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Edward Edward is offline
external usenet poster
 
Posts: 34
Default Operation is not allowed when the object is closed

I am getting data from DB2 and importing into excel. It seems that
when I pull a lot of data I get an error. In debug mode when I look
at the recordset items it says <Operation is not allowed when the
object is closed.

My code looks like this:

Dim oConn As ADODB.Connection
Dim oRs As ADODB.Recordset

sConn = "Persist Security Info=False;Database=MYDB;" & _
"Driver={IBM DB2 ODBC DRIVER};" & _
"Protocol=TCPIP;Hostname=MYDB.XXX.COM;Port=446 ;" & _
"USER ID=" & userid & "; PASSWORD=" & password & ";"

Set oConn = New ADODB.Connection
oConn.Open sConn
Set oRs = New ADODB.Recordset
oRs.Open aSQLCmd, oConn, adOpenStatic, adLockReadOnly, adCmdText

Any idea what is wrong?

Thanks.