Solved

ASP Run Loop Twice

Posted on 2009-05-05
5
447 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
  • 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

816 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

10 Experts available now in Live!

Get 1:1 Help Now