Microsoft ActiveX Data ObjectsMicrosoft ActiveX Data Objects*
*Contents  *Index  *Topic Contents

NextRecordset Method Example

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

Public Sub NextRecordsetX()

	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, , , adCmdText

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

Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.