Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Posts
    13

    Question Unanswered: 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

  2. #2
    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'

  3. #3
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •