ADO » Recordset » NextRecordset

Set recordsetobject = recordsetobject.NextRecordset (RecordsAffected)
The optional RecordsAffected parameter is a long value returned by the provider that is the number of records affected by the current operation.

Clears the current Recordset object and returns the next Recordset object.

The NextRecordset method is called when you want to clear the current Recordset and return the next Recordset.

The next Recordset object can be returned as:

  • a closed recordset with records,
  • a closed non-row returning recordset containing no records,
  • or an empty recordset with both BOF and EOF equal to True.
You should not call this method while the current Recordset is still being edited.

You can use this method to advance through a compound command statement or a stored procedure that needs to return multiple results. For example, in a compound command statement, ADO will process the first query and return the resultant Recordset. By calling the NextRecordset method, you can next process the second query (and so on). After all of the results are returned, the Recordset will be set to nothing.

There is one optional output parameter.


Do While Not objRecordset.State = adStateClosed
   For Each objField In objRecordset.Fields
      Response.Write objField.OriginalValue & VBCRLF
      Response.Write objField.UnderlyingValue & VBCRLF
      Response.Write objField.Value & VBCRLF

   Set objRecordset = objRecordset.NextRecordset

See Also: