BUG: "Command Time Out" Property Does Not WorkID: Q188858
|
Setting the Recordset's dynamic Command Timeout Property does not time out the query.
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
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
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