How to return multiple recordsets in a single execution using ADODB?

后端 未结 1 1289
情书的邮戳
情书的邮戳 2021-01-13 17:20

I need to iterate through multiple recodsets produced by a single query.

However my current connection does not seem to support doing this. So when I do .NextRecords

1条回答
  •  天命终不由人
    2021-01-13 17:42

    Set the CursorLocation to adUseServer (instead of 'client side' )

    Set RS = New ADODB.Recordset
    strSQL = "Select * from States; Select * from Countries;"
    
    With RS
       .CursorLocation = adUseServer
       .ActiveConnection = DB_CONNECTION
       .CursorType = adOpenStatic
       .Open strSQL
    End With
    
    Do
       If Not RS.EOF Then
           'do something
       End If
       Set RS = RS.NextRecordset
       If RS Is Nothing Then
           Exit Do
       End If
    Loop Until RS.State = adStateClosed
    

    0 讨论(0)
提交回复
热议问题