Solved

ASP timeout on rs.movenext

Posted on 2004-04-06
4
1,360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…

734 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