If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > SIMPLE While loop question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-25-06, 20:40
neha101 neha101 is offline
Registered User
 
Join Date: Sep 2006
Posts: 13
Question SIMPLE While loop question

I have following loop. but something is wrong with this loop that i cannot understand. it gets stuck in the loop. PLEASE HELP..
My recordset comes in following format:

id ---- drug

171 --- Coreg
171 --- Avandia
171 --- RS
132--- Coreg
133 --- Avandia
133 --- RS
AND SO ON...

MY CODE:


RS_SpeakerID=""
If (Not objRs.EOF) Then

Do While (NOT objRs.EOF)
if (RS_ID<>objRs("ID")) then

RS_ID= objRs("ID")
count=0

end if


Do while ((objRs("ID")=RS_ID) and (count=0))

if (Ucase(objRs("Drug"))="Coreg") then
response.write "match"


count=1

else


count=0

end if

objRs.MoveNext
LOOP



if (count=0) then

response.write "no match"
end if



objRs.MoveNext
Loop
END IF
Reply With Quote
  #2 (permalink)  
Old 10-04-06, 17:11
csamuels csamuels is offline
Registered User
 
Join Date: Mar 2006
Location: south jersey, usa
Posts: 53
i would debug the code inside this loop

Do while ((objRs("ID")=RS_ID) and (count=0))

it seems you can only break out if count !+ 0
__________________
"They say Moses split the Red Sea
I split the blunt and rolled the fat one, I'm deadly"
-- Tupac 'Blasphemy'
Reply With Quote
  #3 (permalink)  
Old 10-13-06, 08:41
wash wash is offline
Registered User
 
Join Date: Aug 2004
Location: Pune,India
Posts: 94
why do you need to compare count=0 ?

You should drop this condition since the next time the loop comes back the reord has moved to next position. that's why you may be getting a indefinite loop.
Also, i think you should write a Exit statement where your criteria matches in the loop.

Hope this helps.
__________________
In GOD we believe. Everything else we Test!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On