Solved

ADO Recordset Timeout Error

Posted on 2006-06-21
10
1,551 Views
Last Modified: 2013-11-23
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
0
Comment
Question by:uncle_ho
  • 5
  • 5
10 Comments
 
LVL 18

Expert Comment

by:Sethi
ID: 16956611
Try while loop:

While rst.EOF=False

  'code block

  rst.MoveNext       'point at which error occurs
Wend
0
 
LVL 1

Author Comment

by:uncle_ho
ID: 16962694
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.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 16965048
Sure.
0
 
LVL 1

Author Comment

by:uncle_ho
ID: 16994116
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.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 16994538
But I am surprised why you are getting this problem.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Comment

by:uncle_ho
ID: 16994760
Me too.  The error is somewhat sporadic, but seems more frequent with larger recordsets.
0
 
LVL 1

Author Comment

by:uncle_ho
ID: 17004755
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?
0
 
LVL 18

Accepted Solution

by:
Sethi earned 500 total points
ID: 17006203
Not sure. As I see you are specifying ClientSide cursor in your code.
0
 
LVL 1

Author Comment

by:uncle_ho
ID: 17009510
Thanks for your time.  I think I have some DB investigation to do.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 17009606
Do tell me when you come to some conclusion. Thanks.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now