Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot Close an ADO Recordset

Status
Not open for further replies.

sylvanst

Programmer
Jan 15, 2003
8
US
Hello All,

I'm getting a run-time error 3704 that states "Operation is not allowed when the object os closed." when I attempt to close a recordset using ADO (2.5 Library).

Here is my sample code:

*********************************************************
Dim cn As ADODB.Connection
Dim rsStatus As ADODB.Recordset

Set cn = New ADODB.Connection

cn.Open "Provider=SQLOLEDB;Data Source=" & txtServer.Text & ";Initial Catalog=" & txtDatabase.Text & ";User Id=sa;Password=;"

Set rsStatus = New ADODB.Recordset
rsStatus.CursorLocation = adUseClient
rsStatus.LockType = adLockOptimistic

sSQL = "UPDATE " & table1 & " SET [Priority]= '4-None'"
sSQL = sSQL & " Where [OpeningDone] = 'True' and [Store #] = '" & sStore & "'"

rsStatus.Open sSQL, cn

rsStatus.Close <----- Generates a Run-Time error 3704
***********************************************************

Any suggests or comments would be appreciated.

Thanks,

Kent

 

Action queries (UPDATE, DELETE, etc.) do not return recordsets through the .open method and are automatically closed after the call. If you want to double check the closure, you can use:

if rsStatus.State = adStateOpen then
rsStatus.Close
End if

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top