PRB: Requery of ADODB.Recordset Returns Unknown Error Message (80040e4b) with Microsoft Remote Provider (268972)



The information in this article applies to:

  • Microsoft Data Access Components 1.5
  • Microsoft Data Access Components 2.0
  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Remote Data Service for ADO
  • Remote Data Service for ADO 2.0
  • Remote Data Service for ADO 2.1
  • Remote Data Service for ADO 2.5

This article was previously published under Q268972

SYMPTOMS

When you use the Microsoft Remote provider to run a parameterized query against a remote database, the Requery method of the ADODB.Recordset object fails with the following error message:
Unknown Error (80040e4b).

RESOLUTION

To work around this problem delete and then re-create any parameters for the parameterized query before you issue the Requery method.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new Visual Basic project.
  2. From the Projects menu, click References, and then add a reference to Microsoft ActiveX Data Objects.
  3. Paste the following code into the module for Form1:
    Private conn As ADODB.Connection
    Private rs As ADODB.Recordset
    Private cmd As ADODB.Command
    
    Private Sub Form_Load()
    
        Dim strConn As String
        strConn = "Provider=MS Remote;Remote Server=http://MyServer;DSN=Northwind;"
    
        Set conn = New ADODB.Connection
        conn.CursorLocation = adUseClient
        conn.Open strConn
        
        Set cmd = New ADODB.Command
        Set cmd.ActiveConnection = conn
        cmd.CommandText = "Select CategoryName, Description From Categories Where CategoryID=?"
        cmd.Parameters.Append cmd.CreateParameter(, adInteger, adParamInput, , 1)
            
        Set rs = cmd.Execute()
        MsgBox rs("CategoryName")
        
        ' If the following two lines are uncommented, the Requery works.
    
        ' cmd.Parameters.Delete 0
        ' cmd.Parameters.Append cmd.CreateParameter(, adInteger, adParamInput, , 1)
    
        rs.Requery   ' >>> error message "Unknown error" (80040e4b)
        
        rs.Close
        Set rs = Nothing
        Set conn = Nothing
    End Sub
    					
  4. If necessary, modify the connection string and query.
  5. Run the project. The error message described in the "Symptoms" section occurs.

Modification Type:MinorLast Reviewed:8/19/2005
Keywords:kbCodeSnippet kbprb KB268972