Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
i wrote a macro to connect to a database using ADO to retrieve some records Private Sub Display() Dim sql As String Dim con As ADODB.Connection Dim rs1 As ADODB.recordset sql = "select * from table" MsgBox sql Set con = New ADODB.Connection Set rs1 = New ADODB.recordset con.Open "DSN=" & DSN & ";Database=" & DB & ";UID=" _ & User & ";PWD=" & Password rs1.Open sql, con If Not rs1.EOF Then <<---debugger points here.. MsgBox "Yes" Else MsgBox "No" End If rs1.Close con.Close End Sub Whenever i run this, i would get error "Operation is not allowed when the object is closed." and the debugger will point to the statement "If Not rs1.EOF Then...". I tried using "Do Until rs1.EOF" but the error is the same.. Can anyone advise me on what is wrong..thanks very much |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Confusion about how the Window object fits into the Excel object model | Excel Programming | |||
"operation is not allowed when the object is closed" error when us | Excel Programming | |||
Recordset or Object is closed HELP PLEASE! | Excel Programming | |||
Recordset Problem - object is closed | Excel Programming | |||
Operation Is Not Allowed When The Object Is Closed | Excel Programming |