如何使用ADODB在一次执行中返回多个记录集? [英] How to return multiple recordsets in a single execution using ADODB?
本文介绍了如何使用ADODB在一次执行中返回多个记录集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要遍历单个查询生成的多个Recodset。
I need to iterate through multiple recodsets produced by a single query.
但是我当前的连接似乎不支持这样做。因此,当我执行.NextRecordset时,会收到消息:
However my current connection does not seem to support doing this. So when I do .NextRecordset I get the message:
当前提供程序不支持从
一次执行中返回多个记录集
Current provider does not support returning multiple recordsets from a single execution
这是我的连接字符串:
DB_CONNECTION = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Forecasting;Integrated Security=SSPI;"
Call Conn.Open(DB_CONNECTION)
我必须做些什么才能使用。 NextRecordset?
What must I do to be able to use .NextRecordset?
推荐答案
将CursorLocation设置为 adUseServer (而不是客户端)
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
这篇关于如何使用ADODB在一次执行中返回多个记录集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文