Help and Support
 

powered byLive Search

PRB: "Command Time Out" Property Does Not Work

Retired KB ArticleThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Article ID:188858
Last Review:March 2, 2005
Revision:2.1
This article was previously published under Q188858
On This Page

SYMPTOMS

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

Back to the top

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
				

Back to the top

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

Back to the top

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.x Library.
3.Add the following code to a Visual Basic form and run the code:
Note You must change User Id=<username> and Password=<strong password> to the correct values before you run this code. Make sure that User Id has the appropriate permissions to perform this operation on the database.
   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=<server>;" & _
                          "Initial Catalog=pubs;" & _
                          "User Id=<username>;Password=<strong 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

Back to the top


APPLIES TO
Microsoft ActiveX Data Objects 2.0
Microsoft ActiveX Data Objects 2.1 Service Pack 2
Microsoft ActiveX Data Objects 2.5
Microsoft ActiveX Data Objects 2.6
Microsoft ActiveX Data Objects 2.7

Back to the top

Keywords: 
kbbug kbdatabase kbpending kbprb KB188858

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by E-mail, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.