if you are using ADO, try Recordset's NextRecordset method, for example,http://msdn.microsoft.com/library/en-us/ado270/htm/mdaexamples_vb02_6.asp?frame=trueSet Cnxn = New ADODB.Connection
strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
"Initial Catalog='Pubs';Integrated Security='SSPI';"
Cnxn.Open strCnxn
' Open compound recordset
Set rstCompound = New ADODB.Recordset
SQLCompound = "SELECT * FROM Authors; " & _
"SELECT * FROM stores; " & _
"SELECT * FROM jobs"
rstCompound.Open SQLCompound, Cnxn, adOpenStatic, adLockReadOnly, adCmdText
' Display results from each SELECT statement
intCount = 1
Do Until rstCompound Is Nothing
Debug.Print "Contents of recordset #" & intCount
Do Until rstCompound.EOF
Debug.Print , rstCompound.Fields(0), rstCompound.Fields(1)
rstCompound.MoveNext
Loop
Set rstCompound = rstCompound.NextRecordset
intCount = intCount + 1
Loop
' clean up
Cnxn.Close
Set rstCompound = Nothing
Set Cnxn = Nothingif you are using ADO.NET, look into DataReader's NextResult method, or if you are using DataSet, check the third table, :-)
strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
"Initial Catalog='Pubs';Integrated Security='SSPI';"
Cnxn.Open strCnxn
' Open compound recordset
Set rstCompound = New ADODB.Recordset
SQLCompound = "SELECT * FROM Authors; " & _
"SELECT * FROM stores; " & _
"SELECT * FROM jobs"
rstCompound.Open SQLCompound, Cnxn, adOpenStatic, adLockReadOnly, adCmdText
' Display results from each SELECT statement
intCount = 1
Do Until rstCompound Is Nothing
Debug.Print "Contents of recordset #" & intCount
Do Until rstCompound.EOF
Debug.Print , rstCompound.Fields(0), rstCompound.Fields(1)
rstCompound.MoveNext
Loop
Set rstCompound = rstCompound.NextRecordset
intCount = intCount + 1
Loop
' clean up
Cnxn.Close
Set rstCompound = Nothing
Set Cnxn = Nothingif you are using ADO.NET, look into DataReader's NextResult method, or if you are using DataSet, check the third table, :-)
Dim cmd As New ADODB.Command
Dim rs As ADODB.Recordset Cmd.ActiveConnection = "DSN=MySamples;UID=sa"
Cmd.CommandText = "MyNextProc"
Cmd.CommandType = adCmdStoredProcSet rs = Cmd.Execute()
While Not rs Is Nothing
If (Not rs.EOF) Then
Debug.Print rs(0)
End If
Set rs = rs.NextRecordset()
Wend
If (Not rs.EOF) Then <--在这里,对象关闭时候不能操作啊!怎么解决呢?谢谢!
Debug.Print rs(0)
End If
Set rs = rs.NextRecordset()
Wend