我需要迭代由单个查询生成的多个记录集。
但是我当前的连接似乎不支持这样做。所以当我执行 .NextRecordset 时,我收到消息:
当前提供程序不支持从单次执行返回多个记录集
这是我的连接字符串:
DB_CONNECTION = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Forecasting;Integrated Security=SSPI;"
Call Conn.Open(DB_CONNECTION)
Run Code Online (Sandbox Code Playgroud)
我必须做什么才能使用 .NextRecordset?
小智 5
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4751 次 |
| 最近记录: |