PRB: NextRecordset Fails When Called On a Disconnected RecordsetID: Q193352
|
When trying to retrieve the second recordset in a batch query, the following error appears:
The operation requested by the application is not supported by the provider.
This problem can be caused by disconnecting the initial recordset prior to calling NextRecordset.
Do not disconnect the recordset until you have retrieved all of the recordsets in the batch query.
This behavior is by design.
Dim cnPubs As ADODB.Connection
Dim rsBatch As ADODB.Recordset
Private Sub Form_Load()
Dim strConn As String
Dim strSQL As String
strConn = "Provider=MSDASQL;Driver={SQL Server};" & _
"Server=YourServer;Database=pubs;UID=sa;PWD=;"
Set cnPubs = New ADODB.Connection
cnPubs.CursorLocation = adUseClient
cnPubs.Open strConn
strSQL = "SELECT * FROM Authors;" & _
"SELECT * FROM Employee;" & _
"SELECT * FROM Jobs"
Set rsBatch = New ADODB.Recordset
rsBatch.Open strSQL, cnPubs, adOpenStatic, _
adLockOptimistic, adCmdText
If MsgBox("Disconnect the recordset?", vbYesNo) = vbYes Then
Set rsBatch.ActiveConnection = Nothing
End If
Do
Debug.Print rsBatch(0).Name & " = " rsBatch(0)
Set rsBatch = rsBatch.NextRecordset
Loop Until rsBatch Is Nothing
cnPubs.Close
Set cnPubs = Nothing
End Sub
Additional query words:
Keywords : kbADO kbADO200 kbDatabase
Version : WINDOWS:1.5,2.0,5.0,6.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 17, 1999