Solved

ASP Run Loop Twice

Posted on 2009-05-05
5
450 Views
Last Modified: 2012-05-06
I want to run a loop twice. I know it would be more elegant to do all action in one loop but I'm struggling with the syntax and I need the same record set further down the code.  Is the first loop stopping the second?
While  (NOT rsAgents.EOF) 
'Do Action	
rsAgents.MoveNext()
Wend
 
While  (NOT rsAgents.EOF) 
'Do another Action	
rsAgents.MoveNext()
Wend

Open in new window

0
Comment
Question by:webdork
[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
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
Pearl_export_ben earned 500 total points
ID: 24307152
Hope This Helps :)

If you are struggling with code, feel free to open a question with more code and I'll happily debug and explain it to you in more detail
'Scenario 1:
While  (NOT rsAgents.EOF) 
'Do Action      
rsAgents.MoveNext()
Wend
 
'This will take you back up to the top line of your code
rsAgents.MoveFirst()
 
While  (NOT rsAgents.EOF) 
'Do another Action      
rsAgents.MoveNext()
Wend
 
 
'Scenario 2:
While NOT rsAgents.EOF
   Do Action 1
   Do Action 2
   rsAgents.MoveNext
Wend

Open in new window

0
 
LVL 8

Expert Comment

by:Pearl_export_ben
ID: 24307162
And just to add a little more - Yes the first loop was stopping the second.  The first loop would loop through all your results to EOF (End Of File or ResultSet) and then the second loop would pick up where the first left off - at the end of your data - and thus wouldn't be able to manipulate the already played with data.

Ben
0
 
LVL 8

Expert Comment

by:Pearl_export_ben
ID: 24307201
Triple post - I know its naughty - sorry :(

'This will take you back up to the top line of your code
SHOULD BE
'This will take you to the first result in your file/resultset - not the first line of your code.

Ben
0
 

Author Comment

by:webdork
ID: 24307386
Too easy!
rsAgents.MoveFirst() did the trick.
Thanks.
0
 

Author Closing Comment

by:webdork
ID: 31578123
Oh Goody
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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