Re: Do While Loop nested in another While causes error



Thanks for your help

I considered the "Run out of records" problem, but the error comes before
any of the data is written, not at the end.
O well....onto a GROUP solution.

Mal.


"Mike Brind" <uselessfor@xxxxxxxx> wrote in message
news:usFfxulCHHA.1300@xxxxxxxxxxxxxxxxxxxxxxx
Oh I see know. In which case, the approach I offered in my last post is
definitely the way to go. Try to avoid nested loops wherever possible.

If, as an exercise, you want to debug the nested loop, try the
response.write suggestion. If you use On Error Resume Next to suppress
error mesages, set the server.scripttimeout to 10 or so. This will stop
any infinite loops from going on too long. Error 80020009 usually
suggests you have run out of records.

--
Mike Brind


"Mal Reeve" <mal_lori@xxxxxxxxxxx> wrote in message
news:r5k7h.7718$L6.4352@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The WHY is because the query contains (and is searchable) on the Year for
an Alumni.
(from a one to many join). My access query Concats this info into one
field to display.
Eg.
Mike Smith
Years: 2001, 2002, 2003

rather than having 3 listings for him - hence not possible for DISTINCT,
but very doable with GROUP.

HOWEVER...

still doesn't explain why a nested DO loop would cause problems.

Thanks for your help,
Mal.


"Mike Brind" <uselessfor@xxxxxxxx> wrote in message
news:%23hXDSIlCHHA.5012@xxxxxxxxxxxxxxxxxxxxxxx
I can see what you are trying to do - I'm just a bit bemused as to why.
Do all the fields come from the same table? Your field names suggest
they do. If so, why do you have repeating IDs in there?

Until you sort out the contents of the recordset, get rid of your nested
loops and try it like this instead:

idHolder = ""
Do While Not rsGuestbook.EOF
If rsGuestbook("tblAlumniID") <> idHolder Then Response.Write stuff
idHolder = rsGuestbook("tblAlumniID")
rsGuestbook.Movenext
Loop


--
Mike Brind


"Mal Reeve" <mal_lori@xxxxxxxxxxx> wrote in message
news:E0j7h.7691$l25.7681@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
My logic tells me that I don't need an outer movenext
Initially the ID's are the same, so the inner loop does the movenext
eventually it "move'snext" then compares and finds that they are now
different,
in which case it moves back to the outer loop...and cycles again to
display that new ID.

That being said, thanks for the write advice...
And although I can't use a DISTINCT due to some differing data (year
specific), I had not even thought about GROUP...and will explore that.

Mal.


"Mike Brind" <uselessfor@xxxxxxxx> wrote in message
news:eMVwZukCHHA.3916@xxxxxxxxxxxxxxxxxxxxxxx
You are still missing a movenext for the outer loop. Also,
response.Write the value of idHolder within the loop(s) to see if it
is what you expect.

Having said that, why are you trying to cycle through rows until the
ID changes? Why not change the SQL statement to only select unique
tblAlumniID's using GROUP BY Or DISTINCT?

--
Mike Brind


"Mal Reeve" <mal_lori@xxxxxxxxxxx> wrote in message
news:w8i7h.7247$0r.971@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I was summarizing the code...sorry.
Here is the applicable loops in question, thanks for any advice.

Mal.
-----------------------------------------------
'This code follows other page elements.
' Error occurs at second DO loop


rsGuestbook.Open strSQL, adoCon

Response.Write("<table width='100%' border='0' cellpadding='0'
cellspacing='0' bordercolor='#FFFFFF'>")

Dim idHolder

'Loop through the recordset
Do While not rsGuestbook.EOF
Response.Write ("<tr>")
Response.Write ("<td width='15%' valign='top'><font
color='#336633'>First Name: </font></td>")
Response.Write ("<td><strong>")
Response.Write(rsGuestbook("tblAlumniFirstName"))
Response.Write ("</font></td></tr><tr>")
Response.Write ("<td valign='top'></strong><font
color='#336633'>Last Name: </td>")
Response.Write ("<td><strong>")
Response.Write (rsGuestbook("tblAlumniLastName"))
Response.Write ("</font></td></strong></tr>")
if len(rsGuestbook("tblAlumniMaidName")) > 3 then
Response.Write ("<td valign='top'><font
color='#336633'>Maiden Name: </td>")
Response.Write ("<td>")
Response.Write (rsGuestbook("tblAlumniMaidName"))
Response.Write ("</td></tr>")
end if
Response.Write ("<tr>")
Response.Write ("<td valign='top'><font color='#336633'>Email:
</td>")
Response.Write ("<td>")
Response.Write (rsGuestbook("tblAlumniEmail"))
Response.Write ("</td></tr><tr>")
Response.Write ("<td valign='top'><font color='#336633'>Last
Updated: </td>")
Response.Write ("<td>")
Response.Write(rsGuestbook("tblAlumniDateUpdated"))
Response.Write ("</td></tr><tr>")
Response.Write ("<td colspan='2'
align='center'>----------------------------------------------------------------")
Response.Write ("</td></tr>")
idHolder = rsGuestbook("tblAlumniID")
'This loop keeps moving to the next record until it has a
different ID number. ie. A different person
Do until rsGuestbook("tblAlumniID") <> idHolder
rsGuestbook.MoveNext
loop
Loop

'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing


"jane" <bidepan@xxxxxxx> wrote in message
news:%23H$G4kdCHHA.3836@xxxxxxxxxxxxxxxxxxxxxxx
I don't know if you posted your code completely, as so far, there are
following problems
1. the outter loop, why do you have two different recordset name?
myRecordset,rsMyRecordset, are these two indicated one recordset?
2. you don't make a move in outter loop,reMyRecordset.movenext?
3. did you define recordset "reGuestbook"? can not tell from your
code. And make sure rsGuestbook isn't null before the inner loop,
like adding if not eof.
hope these help


"Mal Reeve" <mal_lori@xxxxxxxxxxx> wrote in message
news:hh57h.7074$0r.2737@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,

I have a very basic Page that reads from a database and displays
the information

To display I use a the following basic setup.

Do While Not myRecordset.EOF
...display the info I want in a table.
idHolder = rsMYRecordset("tblAlumniID")
Do until rsGuestbook("tblAlumniID") <> idHolder **this line is
referenced in the error message
rsGuestbook.MoveNext
Loop
Loop

My recordset returns multiple hits for many people (represents
multiple years) I use this inner Do/While Loop to skip displaying
duplicates.
It causes an error '80020009' on the DO UNTIL (nested) loop.

After displaying the error message, it then continues and correctly
displays the data.

I am very much still a noob with ASP.

Any Advice?

Mal.

















.



Relevant Pages

  • Re: Do While Loop nested in another While causes error
    ... Until you sort out the contents of the recordset, ... idHolder = rsGuestbook ... Initially the ID's are the same, so the inner loop does the movenext ... To display I use a the following basic setup. ...
    (microsoft.public.inetserver.asp.db)
  • Re: Do While Loop nested in another While causes error
    ... still doesn't explain why a nested DO loop would cause problems. ... Until you sort out the contents of the recordset, ... display that new ID. ... response.Write the value of idHolder within the loopto see if it ...
    (microsoft.public.inetserver.asp.db)
  • Re: DAO MUCH faster than ADO in this test
    ... DAO is well-known to be faster than ADO. ... Of course the DAO loop ran faster than the SQL loop; ... advantage of a table-type recordset, which only works on local tables. ... Dim starttime As Single, finishtime As Single ...
    (microsoft.public.access.modulesdaovba)
  • Re: Do While Loop nested in another While causes error
    ... Until you sort out the contents of the recordset, ... idHolder = rsGuestbook ... Initially the ID's are the same, so the inner loop does the movenext ... display that new ID. ...
    (microsoft.public.inetserver.asp.db)
  • Re: Do While Loop nested in another While causes error
    ... the outter loop, why do you have two different recordset name? ... myRecordset,rsMyRecordset, are these two indicated one recordset? ... make sure rsGuestbook isn't null before the inner loop, ... To display I use a the following basic setup. ...
    (microsoft.public.inetserver.asp.db)