LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default object is closed

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Confusion about how the Window object fits into the Excel object model Josh Sale Excel Programming 11 April 15th 05 06:08 PM
"operation is not allowed when the object is closed" error when us madhouse Excel Programming 0 January 12th 05 09:05 AM
Recordset or Object is closed HELP PLEASE! DBAL Excel Programming 10 July 28th 04 09:36 AM
Recordset Problem - object is closed DBAL Excel Programming 0 June 4th 04 11:55 PM
Operation Is Not Allowed When The Object Is Closed Mike Carlson Excel Programming 4 October 29th 03 02:18 AM


All times are GMT +1. The time now is 09:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"