NextRecordset Method Example

This example uses the NextRecordset methods to view the data in a recordset that uses a compound command statement made up of three separate SELECT statements.

Public Sub NextRecordsetAdoX()

	Dim rstCompound As ADODB.Recordset
	Dim strCnn As String
	Dim intCount As Integer

	' Open compound recordset.
	strCnn = "driver={SQL Server};server=srv;" & _
		"uid=sa;pwd=;database=pubs"
	
	Set rstCompound = New ADODB.Recordset
	rstCompound.Open "SELECT * FROM authors; " & _
		"SELECT * FROM stores; " & _
		"SELECT * FROM jobs", strCnn

	' Display results from each SELECT statement.
	intCount = 1
	Do Until rstCompound Is Nothing
		With rstCompound
			Debug.Print "Contents of recordset #" & intCount
			Do While Not .EOF
				Debug.Print , .Fields(0), .Fields(1)
				.MoveNext
			Loop
		End With
		
		Set rstCompound = rstCompound.NextRecordset
		intCount = intCount + 1
	Loop
	
End Sub

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.