Hi everyone
I'm a bit confused about the timeout on an ADO command object. I have some code that is opening a recordset. I'm setting the command object timeout to 15 seconds, and using a query that I know takes at least 4 minutes to run in query analyser. The thing is when i run the code it does not time out. Is my understanding of how this should work wrong? The code is inherited i didn't write it, but i can't see why the timeout is not occurring. In this case i have set lTimeout to 15.
This is the code:
Call Connect
If Not m_objConn Is Nothing Then
If m_objConn.State = adStateOpen Then
'// If transactional then start a transaction
If blnTransactional Then
Call m_objConn.BeginTrans
End If
'// Allow the command to take as long as required
objCommand.CommandTimeout = lTimeOut
'// Open the resultset using the command object
Set objCommand.ActiveConnection = m_objConn
Set objRS = New ADODB.Recordset
With objRS
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
Set .ActiveConnection = m_objConn
Call .Open(objCommand)
End With
If (objRS.State = adStateClosed) Then
Set objRS = Nothing
' Call Err.Raise(NULLRECORDSET, "", "Connnection to " & objCommand.Name & " has Failed. " & _
' "Stored Procedure may not exist, or interface may be incompatible with " & _
' "the current version of IMS")
End If
Set ExecuteResultset = objRS
'// If transactional then commit the transaction
If blnTransactional Then
Call m_objConn.CommitTrans
End If
End If
End If
This line here is the one i expect to timeout
Call .Open(objCommand)
but it doesn't!
Any ideas?
Transcend
![[gorgeous] [gorgeous] [gorgeous]](/data/assets/smilies/gorgeous.gif)
I'm a bit confused about the timeout on an ADO command object. I have some code that is opening a recordset. I'm setting the command object timeout to 15 seconds, and using a query that I know takes at least 4 minutes to run in query analyser. The thing is when i run the code it does not time out. Is my understanding of how this should work wrong? The code is inherited i didn't write it, but i can't see why the timeout is not occurring. In this case i have set lTimeout to 15.
This is the code:
Call Connect
If Not m_objConn Is Nothing Then
If m_objConn.State = adStateOpen Then
'// If transactional then start a transaction
If blnTransactional Then
Call m_objConn.BeginTrans
End If
'// Allow the command to take as long as required
objCommand.CommandTimeout = lTimeOut
'// Open the resultset using the command object
Set objCommand.ActiveConnection = m_objConn
Set objRS = New ADODB.Recordset
With objRS
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
Set .ActiveConnection = m_objConn
Call .Open(objCommand)
End With
If (objRS.State = adStateClosed) Then
Set objRS = Nothing
' Call Err.Raise(NULLRECORDSET, "", "Connnection to " & objCommand.Name & " has Failed. " & _
' "Stored Procedure may not exist, or interface may be incompatible with " & _
' "the current version of IMS")
End If
Set ExecuteResultset = objRS
'// If transactional then commit the transaction
If blnTransactional Then
Call m_objConn.CommitTrans
End If
End If
End If
This line here is the one i expect to timeout
Call .Open(objCommand)
but it doesn't!
Any ideas?
Transcend
![[gorgeous] [gorgeous] [gorgeous]](/data/assets/smilies/gorgeous.gif)