PDA

Click to See Complete Forum and Search --> : Opening a Recordset (ADO 2.5)


Sep 2nd, 2000, 04:58 AM
I have an ADO connection and a few recordsets; One of them I have to query a lot.
When I do this:

RS.Open "SELECT * FROM TableName WHERE FieldName = " & ID, DB, adOpenForwardOnly, adLockReadOnly


It gives me an error saying:
Runtime error '3705':
Operation is not allowed when the object is open.

I know I need to close the recordset before querying it again, but when I try to use RS.Close, it says it can't because the object is already closed.

From that I understand that I can call RS.Close only when it's open, but how do I check if the Recordset is open or closed?

And another question:

If I create a connection like this:

DB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb"


Do I have to include a reference to MSJRO.DLL - Microsoft Jet and Replication Objects 2.5 Library?


Thanks.

Kristo
Sep 2nd, 2000, 06:19 PM
That one if the recordset is open
if rs.state = adstateopen then
rs.close
set rs = nothing
end if

This other one if the recordset is closed:

if rs.state = adstateclosed then
your code to open the connection
end if

;)