BUG: NextRecordset Fails on Remoted or Disconnected Records
ID: Q189948
|
The information in this article applies to:
-
ActiveX Data Objects (ADO), versions 1.5, 2.0
-
Remote Data Service for ADO versions 1.5, 2.0
SYMPTOMS
When you call the NextRecordset method on a remoted or disconnected
recordset, the following error message appears:
Run-time error: '3251':
The operation requested by the application is not supported by the
provider.
RESOLUTION
If you are using RDS there is no known workaround.
Refer to the MORE INFORMATION section for information on command_click1. If you are using an ADO code,
do not set the active connection to nothing (that is, do not disconnect the
recordset). Refer to the MORE INFORMATION section for information on command_click2.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. We are researching this bug and will post
new information here in the Microsoft Knowledge Base as it becomes
available.
MORE INFORMATION
Steps to Reproduce Behavior
- Start Visual Basic.
- Create a "Standard EXE" project.
- On the Project menu, choose References and add a reference to Microsoft ActiveX Data Objects 2.0 Library.
- Add two Command buttons to the form.
- Copy the following code into the form. The first Command button's code demonstrates the problem with RDS, and the second Command button's code demonstrates the problem with straight ADO. NOTE: Both examples use the sample tables provided in SQL Server's Pubs database. You might need to alter the connection information in the code so that you can connect to your database:
Private Sub Command1_Click()
Dim ds As Object 'RDS.DataSpace.
Dim df As Object 'RDSServer.DataFactory.
Dim oRsCompound As adodb.Recordset 'Resultset.
Dim iCount As Integer ' Open compound recordset.
Dim sCn As String
Dim sSQL As String
sCn = "Provider=MSDASQL;dsn=localserver;uid=sa;pwd=;database=pubs"
sSQL = "SELECT * FROM authors; " & _
"SELECT * FROM stores; " & _
"SELECT * FROM jobs"
Set ds = CreateObject("RDS.DataSpace")
Set df = ds.CreateObject("RDSServer.DataFactory","http://localhost")
Set oRsCompound = df.Query(sCn, sSQL)
Do Until oRsCompound Is Nothing
Debug.Print "Contents of recordset #" & iCount
Do While Not oRsCompound.EOF
Debug.Print , oRsCompound.Fields(0), oRsCompound.Fields(1)
oRsCompound.MoveNext
Loop
Set oRsCompound = oRsCompound.NextRecordset
iCount = iCount + 1
Loop
End Sub
Private Sub Command2_Click()
Dim oRsCompound As adodb.Recordset
Dim iCount As Integer ' Open compound recordset.
Dim sCn As String
Dim sSQL As String
sCn = "Provider=SQLSQLOLDB;" & _
"Data Source=servername;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;Password=;"
sSQL = "SELECT * FROM authors; " & _
"SELECT * FROM stores; " & _
"SELECT * FROM jobs"
Set oRsCompound = New adodb.Recordset
oRsCompound.CursorLocation = adUseClient
oRsCompound.Open sSQL, _
sCn, _
adOpenUnspecified, _
adLockUnspecified
'If next line is commented out it works.
Set oRsCompound.ActiveConnection = Nothing
Do Until oRsCompound Is Nothing
Debug.Print "Contents of recordset #" & iCount
Do While Not oRsCompound.EOF
Debug.Print , oRsCompound.Fields(0), _
oRsCompound.Fields(1)
oRsCompound.MoveNext
Loop
Set oRsCompound = oRsCompound.NextRecordset
iCount = iCount + 1
Loop
End Sub
Additional query words:
Keywords : kbADO150bug kbADO200bug kbDatabase kbRDS kbRDS150bug kbRDS200bug kbVBp600
Version : WINDOWS:1.5,2.0
Platform : WINDOWS
Issue type : kbbug