Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: Error Message "Async Operation Is Pending" Using RDS DataControl


View products that this article applies to.

This article was previously published under Q245509

↑ Back to the top


Symptoms

If you try to access the methods or properties of an RDS DataControl object that has been executed asynchronously, you see one of the following errors:
Run-time error '4113': Can't perform operation with an async operation pending
-or-
Run-time error '4113': Operation cannot be performed while async operation is pending.
-or-
Run-time error '91': Object variable or With block variable not set
The error occurs when you try to use the DataControl's Recordset collection, SortColumn property, Refresh method, or Reset method.

The errors occur despite checking the status of the Data Control's ReadyState flag to see if execution is complete.

↑ Back to the top


Cause

The errors occur because the DataControl is still executing the recordset.

Although it should be possible to use the DataControl's ReadyState property to determine when the execution is finished, ReadyState incorrectly indicates that execution is complete before execution is actually complete. That is, the flag that signals the end of the asynchronous execution does not get set until after the ReadyState flag has been set and the ReadyState notification has fired.

The same behavior occurs when using the DataControl's OnReadyStateChange event.
The ReadyState is incorrectly reported as complete if checked within the OnReadyStateChange event.

↑ Back to the top


Resolution

One workaround is to change the ExecuteOptions property of the DataControl to 1, adcExecSync, so that execution is synchronous.

↑ Back to the top


Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


More information

Steps to Reproduce Behavior

The following code uses the Pubs database that comes with SQL Server. The sample uses Visual Basic, but can easily be adapted to VBScript.
  1. In Visual Basic, create a new Standard EXE. Form1 is created by default.
  2. Add a CommandButton to Form1. Command1 is created by default
  3. Paste the following code into Form1's Code window:

    Note You must change User ID=<User ID> and Password=<Strong Password> to the correct values. Make sure that User ID has the appropriate permissions to perform this operation on the database.
       Private Sub Command1_Click()
    
          Dim dc
          Set dc = CreateObject("RDS.DataControl")
      
          'Open asynchronously
          dc.ExecuteOptions = 2  'adcExecAsync
      
          'Uncomment this line to workaround
          'dc.ExecuteOptions = 1  'adcExecSync
      
          dc.SQL = "select * from authors"
          dc.Connect = "Provider=SQLOLEDB;Data Source=servername;" & _
                       "Initial Catalog=Pubs;User ID=<User ID>;Password=<Strong Password>;"
      
          'Open the recordset
          dc.Refresh
      
          'Check to see when execution is finished
          Do While dc.ReadyState <> 4  'adcReadyStateComplete
              DoEvents
          Loop
    
          'Sort the recordset
           dc.SortColumn = "au_id"
           dc.Reset
    
       End Sub
  4. In the code, modify the Data Control's Connect property so that the Data Source uses your server and a valid User ID and Password.
  5. Run the program. Click Command1. Note run-time error 4113.
  6. Uncomment the code that sets the DataControl's ExecuteOptions property to 1, which is adcExecSync.
  7. Again run the program. Click Command1. The code completes successfully.

↑ Back to the top


References

For additional information on the Remote Data Service DataControl, please refer to the topic "RDS.Data Control" in MSDN Online Help.

↑ Back to the top


Keywords: kbbug, kbdatabase, kbpending, KB245509

↑ Back to the top

Article Info
Article ID : 245509
Revision : 6
Created on : 2/12/2007
Published on : 2/12/2007
Exists online : False
Views : 422