Solved

ASP timeout on rs.movenext

Posted on 2004-04-06
4
1,351 Views
Last Modified: 2012-05-04
Hi,
I'm trying to return a record set from a stored procedure on SQL Server7.  The app seems to to timeout and reports the failure at the include file where the line is ...
while (!rs.eof) { reccnt++; rs.movenext(); }
I have tracked it down to being the actual rs.movenext() line but can't find a way around it or why it's falling over.  The stored procedure works fine and returns results when running it asa query through Access in about 10 seconds.  Via asp it just hangs.  Can anyone help me please?
Thanks in advance.
0
Comment
Question by:PranP
4 Comments
 
LVL 11

Accepted Solution

by:
Slimshaneey earned 500 total points
ID: 10765249
You can get the recordcount by using code like the following:

reccount = rs.recordcount

If it returns a value of -1 then you need to add this line before the recordset is created:
YourConnection.Cursorlocation = 3
0
 
LVL 15

Expert Comment

by:deighc
ID: 10765379
If all you want is a count of records from the database then use a SELECT COUNT(*) query.

This is alot faster than using the recordCount property of a the recordset object because you don't need a client-side static or keyset cursor (which are the slowest cursor types) and you only have a single record in your recordset.

In fact, if you're using a stored procedure and all you want to know is a record count then the absolute best performance will come by setting your record count as an output parameter of the stored procedure then using a command object to read the output parameter. That way you don't need a recordset object at all.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10765381
What language?  C#?

Post more code..
0
 

Author Comment

by:PranP
ID: 10765653
Thanks Slimshaneey,
The YourConnection.CursorLocation did the trick.  Pulled back results stragiht away.

Many Thanks,
PranP
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

943 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

6 Experts available now in Live!

Get 1:1 Help Now