Library code snippets
Reuse ADO recordsets
Often, you may want to reuse a recordset object in the same procedure. For
instance, you may want to open a new SQL statement. If so, you may have wondered
if it was necessary to destroy a recordset object before reusing it again, as in
the following:
Fortunately, destroying the recordset object variable isn't necessary. ADO lets
you reuse a recordset as much as you like, so long as you close it first. As a
result, you could modify the above pseudo-code to look something like this:
'process first RS
Set RS = New ADODB.Recordset
RS.Open SQL, Conn, ....
' do something with the RS
RS.Close
Set RS = Nothing
'process second RS
Set RS = New ADODB.Recordset
RS.Open SQL, Conn, ....
' do something with the RS
RS.Close
Set RS = NothingSet RS = New ADODB.Recordset
'process first RS
RS.Open SQL, Conn, ....
' do something with the RS
RS.Close
'process second RS
RS.Open SQL, Conn, ....
' do something with the RS
RS.Close
Set RS = Nothing
Related articles
Related discussion
-
Help to Call ASP function from onclick event in HTML to pass an array
by vka (0 replies)
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
Variable In Vb.Net
by chia (0 replies)
-
ideas in building a captive portal
by sjranjan (2 replies)
-
How to debug classic ASP pages during AJAX calls in ASP.NET website
by andwan0 (0 replies)
Related podcasts
-
Scott Guthrie
Scott catches up with Scott Guthrie in an interview covering Ajax, Asp 2.0, extender controls, CSS adapters and more.
This thread is for discussions of Reuse ADO recordsets.