BUG: NextRecordset Fails on Remoted or Disconnected Records (189948)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 1.5
  • ActiveX Data Objects (ADO) 2.0
  • ActiveX Data Objects (ADO) 2.1 SP2
  • ActiveX Data Objects (ADO) 2.5
  • ActiveX Data Objects (ADO) 2.6
  • ActiveX Data Objects (ADO) 2.7
  • Remote Data Service for ADO 1.5
  • Remote Data Service for ADO 2.0
  • Remote Data Service for ADO 2.1 SP2
  • Remote Data Service for ADO 2.5
  • Remote Data Service for ADO 2.6
  • Remote Data Service for ADO 2.7

This article was previously published under Q189948

SYMPTOMS

When you call the NextRecordset method on a remoted or disconnected recordset, one of the following error message appears:
Run-time error: '3251':
The operation requested by the application is not supported by the provider.

-or-

The object or provider is not capable of performing requested operation.

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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start Visual Basic.
  2. Create a "Standard EXE" project.
  3. On the Project menu, choose References and add a reference to Microsoft ActiveX Data Objects Library.
  4. Add two Command buttons to the form.
  5. 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 must change <username> and <strong password> to the correct values before you run this code. Make sure that UID has the appropriate permissions to perform this operation on the 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=<username>;pwd=<strong password>;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=SQLOLEDB;" & _
                "Data Source=servername;" & _
                "Initial Catalog=pubs;" & _
                "User Id=<username>;Password=<strong 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
    					

Modification Type:MinorLast Reviewed:3/2/2005
Keywords:kbBug kbDatabase kbnofix KB189948