Link to home
Start Free TrialLog in
Avatar of uncle_ho
uncle_hoFlag for United States of America

asked on

ADO Recordset Timeout Error

Dear Experts,
I am working with an ADO recordset in a VBScript and am encountering the following error:

Code: 80004005
Error: [Microsoft][ODBC SQL Server Driver] Timeout Expired
Source: Microsoft OLEDB Provider for ODBC Drivers

The error is thrown when I call MoveNext within a Do While loop:

Do While Not rst.EOF

  'code block

  rst.MoveNext       'point at which error occurs
Loop

It seems to only occur when it is on the last record and should be moving to EOF.  I am not explicitly setting any connection or command timeout.  Recordset properties are as follows:

rst.CursorType = 3            'adOpenStatic
rst.CursorLocation = 3       'adUseClient
rst.LockType = 1               'adLockReadOnly

What is baffling to me is that I don't get timeout errors at any other point, but only when it's at the last record.  Any ideas as to why it only happens then?  I don't think I've ever encountered this before.  Thanks in advance for suggestions.

-Chris
Avatar of Sethi
Sethi
Flag of India image

Try while loop:

While rst.EOF=False

  'code block

  rst.MoveNext       'point at which error occurs
Wend
Avatar of uncle_ho

ASKER

Sorry Sethi, but I still haven't had a chance to test this out.  I'll let you know how it works out once I can get around to it.  Thanks for the help.
Sure.
Tried the while loop, but ran into same errors.  As a workaround, I am now retrieving the record count after opening the recordset, then using a For loop.  Before MoveNext is called, I compare the counter to the total record count and if it is already on the last record and would be going to EOF, I never call movenext.  Seems to be sufficient.  I may also try a disconnected recordset, if I have a chance.

Thanks.
But I am surprised why you are getting this problem.
Me too.  The error is somewhat sporadic, but seems more frequent with larger recordsets.
UPDATE:  calling RecordCount has also been timing out, as well as a MoveLast call, so my work-around didn't prove to be very effective.  I ran a SQL Server trace and saw that there were a ton of sp_cursorfetch calls generated by the recordset, even though I'm specifying client-side cursors in the connection object and the recordset object.  I know I'm getting into more of a database area than programming, but any idea why it appears to be using server-side cursors?
ASKER CERTIFIED SOLUTION
Avatar of Sethi
Sethi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your time.  I think I have some DB investigation to do.
Do tell me when you come to some conclusion. Thanks.