BUG: "Command Time Out" Property Does Not Work

ID: Q188858


The information in this article applies to:


SYMPTOMS

Setting the Recordset's dynamic Command Timeout Property does not time out the query.


RESOLUTION

One workaround for this problem is to switch the cursor from adUseClient to adUseServer.

If adUseClient is necessary, another workaround is to use a Command object as the source of the Recordset and use the Command object's CommandTimeout property, for example:


   'Assuming a connection object has been established
   With oCm

      Set .ActiveConnection = oCn
      .CommandText = "select * from authors"
      .CommandType = adCmdText
      .CommandTimeout = 10

   End With

   With oRs

      .CursorLocation = adUseClient
      .Open oCm

   End With 


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. Create a new Visual Basic project.


  2. On the Project menu, click References, and select Microsoft ActiveX Data Objects 2.0 Library.


  3. Add the following code to a Visual Basic form and run the code:
    
       Dim oCn As Connection
       Dim oRs As Recordset
       Dim oCm as Command
    
       Set oCn = New Connection
       Set oRs = New Recordset
       Set oCm = New Command
    
       With oCn
          .ConnectionString = "PROVIDER=SQLOLEDB;" & _
                              "DATA SOURCE=matthofa;" & _
                              "Initial Catalog=pubs;" & _
                              "User Id=sa;Password="
          .Open
       End With
    
       'Create a Stored Procedure on SQL Server that causes a delay.
       With oCM
          Set .ActiveConnection = oCn
          .CommandText = "Create Procedure MyWait AS " & _
                          "waitfor delay '00:00:15'"
          .CommandType = adCmdText
          .Execute
       End With
    
       'The Command Time out does not occur.
       With oRs
          Set .ActiveConnection = oCn
          .CursorLocation = adUseClient
          .Properties("Command Time out") = 5
          .Open "MyWait"
       End With 


Additional query words: kbado200 kbado kbADO200bug


Keywords          : kbADO200 kbADO200bug 
Version           : WINDOWS:2.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: May 27, 1999