Microsoft KB Archive/188858

= PRB: "Command Time Out" Property Does Not Work =

Article ID: 188858

Article Last Modified on 3/2/2005

-

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

-



This article was previously published under Q188858



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.



Steps to Reproduce Behavior
 Create a new Visual Basic project. On the Project menu, click References, and select Microsoft ActiveX Data Objects 2.x Library.  Add the following code to a Visual Basic form and run the code:

Note You must change User Id= and 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= ;" & _ "Initial Catalog=pubs;" & _ "User Id= ;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 

Keywords: kbbug kbdatabase kbprb kbpending KB188858

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.