Do While Loop nested in another While causes error

Do While Loop nested in another While causes error

am 16.11.2006 23:06:05 von Mal Reeve

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.

Re: Do While Loop nested in another While causes error

am 17.11.2006 00:44:41 von Jane

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" wrote in message
news:hh57h.7074$0r.2737@newsread1.news.pas.earthlink.net...
> 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.
>

Re: Do While Loop nested in another While causes error

am 17.11.2006 13:44:12 von Mal Reeve

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("

cellspacing='0' bordercolor='#FFFFFF'>")

Dim idHolder

'Loop through the recordset
Do While not rsGuestbook.EOF
Response.Write ("")
Response.Write ("")
Response.Write ("")
Response.Write ("")
Response.Write ("")
if len(rsGuestbook("tblAlumniMaidName")) > 3 then
Response.Write ("")
Response.Write ("")
end if
Response.Write ("")
Response.Write ("")
Response.Write ("")
Response.Write ("")
Response.Write ("")
Response.Write ("")
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" wrote in message
news:%23H$G4kdCHHA.3836@TK2MSFTNGP02.phx.gbl...
>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" wrote in message
> news:hh57h.7074$0r.2737@newsread1.news.pas.earthlink.net...
>> 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.
>>
>
>

Re: Do While Loop nested in another While causes error

am 17.11.2006 14:23:35 von Mike Brind

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" wrote in message
news:w8i7h.7247$0r.971@newsread1.news.pas.earthlink.net...
>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("

color='#336633'>First Name: ")
Response.Write(rsGuestbook("tblAlumniFirstName"))
Response.Write ("
Last
Name:
")
Response.Write (rsGuestbook("tblAlumniLastName"))
Response.Write ("
Maiden
Name:
")
Response.Write (rsGuestbook("tblAlumniMaidName"))
Response.Write ("
Email: ")
Response.Write (rsGuestbook("tblAlumniEmail"))
Response.Write ("
Last Updated:
")
Response.Write(rsGuestbook("tblAlumniDateUpdated"))
Response.Write ("
align='center'>--------------------------------------------- -------------------")
Response.Write ("
> cellspacing='0' bordercolor='#FFFFFF'>")
>
> Dim idHolder
>
> 'Loop through the recordset
> Do While not rsGuestbook.EOF
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> if len(rsGuestbook("tblAlumniMaidName")) > 3 then
> Response.Write ("")
> Response.Write ("")
> end if
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> 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" wrote in message
> news:%23H$G4kdCHHA.3836@TK2MSFTNGP02.phx.gbl...
>>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" wrote in message
>> news:hh57h.7074$0r.2737@newsread1.news.pas.earthlink.net...
>>> 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.
>>>
>>
>>
>
>

Re: Do While Loop nested in another While causes error

am 17.11.2006 14:44:04 von Mal Reeve

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" wrote in message
news:eMVwZukCHHA.3916@TK2MSFTNGP06.phx.gbl...
> 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" wrote in message
> news:w8i7h.7247$0r.971@newsread1.news.pas.earthlink.net...
>>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("

> color='#336633'>First Name: ")
> Response.Write(rsGuestbook("tblAlumniFirstName"))
> Response.Write ("
Last
> Name:
")
> Response.Write (rsGuestbook("tblAlumniLastName"))
> Response.Write ("
Maiden
> Name:
")
> Response.Write (rsGuestbook("tblAlumniMaidName"))
> Response.Write ("
Email: ")
> Response.Write (rsGuestbook("tblAlumniEmail"))
> Response.Write ("
Last Updated:
>
")
> Response.Write(rsGuestbook("tblAlumniDateUpdated"))
> Response.Write ("
> align='center'>--------------------------------------------- -------------------")
> Response.Write ("
>> cellspacing='0' bordercolor='#FFFFFF'>")
>>
>> Dim idHolder
>>
>> 'Loop through the recordset
>> Do While not rsGuestbook.EOF
>> Response.Write ("")
>> Response.Write ("")
>> Response.Write ("")
>> Response.Write ("")
>> Response.Write ("")
>> if len(rsGuestbook("tblAlumniMaidName")) > 3 then
>> Response.Write ("")
>> Response.Write ("")
>> end if
>> Response.Write ("")
>> Response.Write ("")
>> Response.Write ("")
>> Response.Write ("")
>> Response.Write ("")
>> Response.Write ("")
>> 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" wrote in message
>> news:%23H$G4kdCHHA.3836@TK2MSFTNGP02.phx.gbl...
>>>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" wrote in message
>>> news:hh57h.7074$0r.2737@newsread1.news.pas.earthlink.net...
>>>> 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.
>>>>
>>>
>>>
>>
>>
>
>

Re: Do While Loop nested in another While causes error

am 17.11.2006 15:09:51 von Mike Brind

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" wrote in message
news:E0j7h.7691$l25.7681@newsread4.news.pas.earthlink.net...
> 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" wrote in message
> news:eMVwZukCHHA.3916@TK2MSFTNGP06.phx.gbl...
>> 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" wrote in message
>> news:w8i7h.7247$0r.971@newsread1.news.pas.earthlink.net...
>>>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("

>> color='#336633'>First Name: ")
>> Response.Write(rsGuestbook("tblAlumniFirstName"))
>> Response.Write ("
Last
>> Name:
")
>> Response.Write (rsGuestbook("tblAlumniLastName"))
>> Response.Write ("
Maiden
>> Name:
")
>> Response.Write (rsGuestbook("tblAlumniMaidName"))
>> Response.Write ("
Email:
>>
")
>> Response.Write (rsGuestbook("tblAlumniEmail"))
>> Response.Write ("
Last Updated:
>>
")
>> Response.Write(rsGuestbook("tblAlumniDateUpdated"))
>> Response.Write ("
>> align='center'>--------------------------------------------- -------------------")
>> Response.Write ("
>>> cellspacing='0' bordercolor='#FFFFFF'>")
>>>
>>> Dim idHolder
>>>
>>> 'Loop through the recordset
>>> Do While not rsGuestbook.EOF
>>> Response.Write ("")
>>> Response.Write ("")
>>> Response.Write ("")
>>> Response.Write ("")
>>> Response.Write ("")
>>> if len(rsGuestbook("tblAlumniMaidName")) > 3 then
>>> Response.Write ("")
>>> Response.Write ("")
>>> end if
>>> Response.Write ("")
>>> Response.Write ("")
>>> Response.Write ("")
>>> Response.Write ("")
>>> Response.Write ("")
>>> Response.Write ("")
>>> 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" wrote in message
>>> news:%23H$G4kdCHHA.3836@TK2MSFTNGP02.phx.gbl...
>>>>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" wrote in message
>>>> news:hh57h.7074$0r.2737@newsread1.news.pas.earthlink.net...
>>>>> 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.
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

Re: Do While Loop nested in another While causes error

am 17.11.2006 15:57:27 von Mal Reeve

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" wrote in message
news:%23hXDSIlCHHA.5012@TK2MSFTNGP06.phx.gbl...
>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" wrote in message
> news:E0j7h.7691$l25.7681@newsread4.news.pas.earthlink.net...
>> 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" wrote in message
>> news:eMVwZukCHHA.3916@TK2MSFTNGP06.phx.gbl...
>>> 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" wrote in message
>>> news:w8i7h.7247$0r.971@newsread1.news.pas.earthlink.net...
>>>>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("

>>> color='#336633'>First Name: ")
>>> Response.Write(rsGuestbook("tblAlumniFirstName"))
>>> Response.Write ("
>>> color='#336633'>Last Name: ")
>>> Response.Write (rsGuestbook("tblAlumniLastName"))
>>> Response.Write ("
>>> color='#336633'>Maiden Name: ")
>>> Response.Write (rsGuestbook("tblAlumniMaidName"))
>>> Response.Write ("
Email:
>>>
")
>>> Response.Write (rsGuestbook("tblAlumniEmail"))
>>> Response.Write ("
Last Updated:
>>>
")
>>> Response.Write(rsGuestbook("tblAlumniDateUpdated"))
>>> Response.Write ("
>>> align='center'>--------------------------------------------- -------------------")
>>> Response.Write ("
>>>> cellspacing='0' bordercolor='#FFFFFF'>")
>>>>
>>>> Dim idHolder
>>>>
>>>> 'Loop through the recordset
>>>> Do While not rsGuestbook.EOF
>>>> Response.Write ("")
>>>> Response.Write ("")
>>>> Response.Write ("")
>>>> Response.Write ("")
>>>> Response.Write ("")
>>>> if len(rsGuestbook("tblAlumniMaidName")) > 3 then
>>>> Response.Write ("")
>>>> Response.Write ("")
>>>> end if
>>>> Response.Write ("")
>>>> Response.Write ("")
>>>> Response.Write ("")
>>>> Response.Write ("")
>>>> Response.Write ("")
>>>> Response.Write ("")
>>>> 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" wrote in message
>>>> news:%23H$G4kdCHHA.3836@TK2MSFTNGP02.phx.gbl...
>>>>>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" wrote in message
>>>>> news:hh57h.7074$0r.2737@newsread1.news.pas.earthlink.net...
>>>>>> 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.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

Re: Do While Loop nested in another While causes error

am 17.11.2006 16:18:41 von Mike Brind

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" wrote in message
news:r5k7h.7718$L6.4352@newsread3.news.pas.earthlink.net...
> 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" wrote in message
> news:%23hXDSIlCHHA.5012@TK2MSFTNGP06.phx.gbl...
>>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" wrote in message
>> news:E0j7h.7691$l25.7681@newsread4.news.pas.earthlink.net...
>>> 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" wrote in message
>>> news:eMVwZukCHHA.3916@TK2MSFTNGP06.phx.gbl...
>>>> 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" wrote in message
>>>> news:w8i7h.7247$0r.971@newsread1.news.pas.earthlink.net...
>>>>>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("

>>>> color='#336633'>First Name: ")
>>>> Response.Write(rsGuestbook("tblAlumniFirstName"))
>>>> Response.Write ("
>>>> color='#336633'>Last Name: ")
>>>> Response.Write (rsGuestbook("tblAlumniLastName"))
>>>> Response.Write ("
>>>> color='#336633'>Maiden Name: ")
>>>> Response.Write (rsGuestbook("tblAlumniMaidName"))
>>>> Response.Write ("
Email:
>>>>
")
>>>> Response.Write (rsGuestbook("tblAlumniEmail"))
>>>> Response.Write ("
Last
>>>> Updated:
")
>>>> Response.Write(rsGuestbook("tblAlumniDateUpdated"))
>>>> Response.Write ("
>>>> align='center'>--------------------------------------------- -------------------")
>>>> Response.Write ("
>>>>> cellspacing='0' bordercolor='#FFFFFF'>")
>>>>>
>>>>> Dim idHolder
>>>>>
>>>>> 'Loop through the recordset
>>>>> Do While not rsGuestbook.EOF
>>>>> Response.Write ("")
>>>>> Response.Write ("")
>>>>> Response.Write ("")
>>>>> Response.Write ("")
>>>>> Response.Write ("")
>>>>> if len(rsGuestbook("tblAlumniMaidName")) > 3 then
>>>>> Response.Write ("")
>>>>> Response.Write ("")
>>>>> end if
>>>>> Response.Write ("")
>>>>> Response.Write ("")
>>>>> Response.Write ("")
>>>>> Response.Write ("")
>>>>> Response.Write ("")
>>>>> Response.Write ("")
>>>>> 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" wrote in message
>>>>> news:%23H$G4kdCHHA.3836@TK2MSFTNGP02.phx.gbl...
>>>>>>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" wrote in message
>>>>>> news:hh57h.7074$0r.2737@newsread1.news.pas.earthlink.net...
>>>>>>> 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.
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

Re: Do While Loop nested in another While causes error

am 17.11.2006 16:21:47 von Anthony Jones

"Mal Reeve" wrote in message
news:w8i7h.7247$0r.971@newsread1.news.pas.earthlink.net...
> 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("

>>>>> color='#336633'>First Name: ")
>>>>> Response.Write(rsGuestbook("tblAlumniFirstName"))
>>>>> Response.Write ("
>>>>> color='#336633'>Last Name: ")
>>>>> Response.Write (rsGuestbook("tblAlumniLastName"))
>>>>> Response.Write ("
>>>>> color='#336633'>Maiden Name: ")
>>>>> Response.Write (rsGuestbook("tblAlumniMaidName"))
>>>>> Response.Write ("
Email:
>>>>>
")
>>>>> Response.Write (rsGuestbook("tblAlumniEmail"))
>>>>> Response.Write ("
Last
>>>>> Updated:
")
>>>>> Response.Write(rsGuestbook("tblAlumniDateUpdated"))
>>>>> Response.Write ("
>>>>> align='center'>--------------------------------------------- -------------------")
>>>>> Response.Write ("
> cellspacing='0' bordercolor='#FFFFFF'>")
>
> Dim idHolder
>
> 'Loop through the recordset
> Do While not rsGuestbook.EOF
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> if len(rsGuestbook("tblAlumniMaidName")) > 3 then
> Response.Write ("")
> Response.Write ("")
> end if
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> Response.Write ("")
> 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

What happens when the movenext results in the EOF? It will still loop to
the Do Until condition only this time rsGuestbook("tblAlumniID") will result
in an error since EOF is true.

This would be better (in that it'll work):-

Do Until rsGuestbook.EOF
IF rsGuestbook("tblAlumniID") <> idHolder Then Exit Do
rsGuestbook.moveNext
Loop

However you already have a do until loop on the EOF so you could change the
outer loop to:-


Do Until rsGuestbook.EOF
If rsGuestbook("tblAlumniID") <> idHolder Then
'All your response.write code here
idHolder = rsGuestbook("tblAlumniID")
End If
rsGuestbook.MoveNext
Loop

That said I agree with Mike get SQL to do this work using a GROUP BY clause.
Having ADO return a a result set that is larger than it needs to be in to
VBScript is going to be way slower.



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

Re: Do While Loop nested in another While causes error

am 17.11.2006 19:33:57 von Mal Reeve

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" wrote in message
news:usFfxulCHHA.1300@TK2MSFTNGP03.phx.gbl...
> 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" wrote in message
> news:r5k7h.7718$L6.4352@newsread3.news.pas.earthlink.net...
>> 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" wrote in message
>> news:%23hXDSIlCHHA.5012@TK2MSFTNGP06.phx.gbl...
>>>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" wrote in message
>>> news:E0j7h.7691$l25.7681@newsread4.news.pas.earthlink.net...
>>>> 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" wrote in message
>>>> news:eMVwZukCHHA.3916@TK2MSFTNGP06.phx.gbl...
>>>>> 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" wrote in message
>>>>> news:w8i7h.7247$0r.971@newsread1.news.pas.earthlink.net...
>>>>>>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("

> color='#336633'>First Name: ")
> Response.Write(rsGuestbook("tblAlumniFirstName"))
> Response.Write ("
Last
> Name:
")
> Response.Write (rsGuestbook("tblAlumniLastName"))
> Response.Write ("
Maiden
> Name:
")
> Response.Write (rsGuestbook("tblAlumniMaidName"))
> Response.Write ("
Email:
")
> Response.Write (rsGuestbook("tblAlumniEmail"))
> Response.Write ("
Last Updated:
>
")
> Response.Write(rsGuestbook("tblAlumniDateUpdated"))
> Response.Write ("
>
align='center'>--------------------------------------------- ----------------
---")
> Response.Write ("
>>>>>> cellspacing='0' bordercolor='#FFFFFF'>")
>>>>>>
>>>>>> Dim idHolder
>>>>>>
>>>>>> 'Loop through the recordset
>>>>>> Do While not rsGuestbook.EOF
>>>>>> Response.Write ("")
>>>>>> Response.Write ("")
>>>>>> Response.Write ("")
>>>>>> Response.Write ("")
>>>>>> Response.Write ("")
>>>>>> if len(rsGuestbook("tblAlumniMaidName")) > 3 then
>>>>>> Response.Write ("")
>>>>>> Response.Write ("")
>>>>>> end if
>>>>>> Response.Write ("")
>>>>>> Response.Write ("")
>>>>>> Response.Write ("")
>>>>>> Response.Write ("")
>>>>>> Response.Write ("")
>>>>>> Response.Write ("")
>>>>>> 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" wrote in message
>>>>>> news:%23H$G4kdCHHA.3836@TK2MSFTNGP02.phx.gbl...
>>>>>>>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" wrote in message
>>>>>>> news:hh57h.7074$0r.2737@newsread1.news.pas.earthlink.net...
>>>>>>>> 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.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

Re: Do While Loop nested in another While causes error

am 17.11.2006 21:26:18 von Anthony Jones

"Mal Reeve" wrote in message
news:pgn7h.4$sf5.2@newsread4.news.pas.earthlink.net...
> 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.

How do you know that?

Have you set response.buffer = false??

> O well....onto a GROUP solution.
>
> Mal.
>
>
> "Mike Brind" wrote in message
> news:usFfxulCHHA.1300@TK2MSFTNGP03.phx.gbl...
> > 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" wrote in message
> > news:r5k7h.7718$L6.4352@newsread3.news.pas.earthlink.net...
> >> 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" wrote in message
> >> news:%23hXDSIlCHHA.5012@TK2MSFTNGP06.phx.gbl...
> >>>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" wrote in message
> >>> news:E0j7h.7691$l25.7681@newsread4.news.pas.earthlink.net...
> >>>> 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" wrote in message
> >>>> news:eMVwZukCHHA.3916@TK2MSFTNGP06.phx.gbl...
> >>>>> 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" wrote in message
> >>>>> news:w8i7h.7247$0r.971@newsread1.news.pas.earthlink.net...
> >>>>>>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("

>>>>>> color='#336633'>First Name: ")
>>>>>> Response.Write(rsGuestbook("tblAlumniFirstName"))
>>>>>> Response.Write ("
>>>>>> color='#336633'>Last Name: ")
>>>>>> Response.Write (rsGuestbook("tblAlumniLastName"))
>>>>>> Response.Write ("
>>>>>> color='#336633'>Maiden Name: ")
>>>>>> Response.Write (rsGuestbook("tblAlumniMaidName"))
>>>>>> Response.Write ("
Email:
>>>>>>
")
>>>>>> Response.Write (rsGuestbook("tblAlumniEmail"))
>>>>>> Response.Write ("
Last
>>>>>> Updated:
")
>>>>>> Response.Write(rsGuestbook("tblAlumniDateUpdated"))
>>>>>> Response.Write ("
>>>>>> align='center'>--------------------------------------------- -------------------")
>>>>>> Response.Write ("
> >>>>>> cellspacing='0' bordercolor='#FFFFFF'>")
> >>>>>>
> >>>>>> Dim idHolder
> >>>>>>
> >>>>>> 'Loop through the recordset
> >>>>>> Do While not rsGuestbook.EOF
> >>>>>> Response.Write ("")
> >>>>>> Response.Write ("")
> >>>>>> Response.Write ("")
> >>>>>> Response.Write ("")
> >>>>>> Response.Write ("")
> >>>>>> if len(rsGuestbook("tblAlumniMaidName")) > 3 then
> >>>>>> Response.Write ("")
> >>>>>> Response.Write ("")
> >>>>>> end if
> >>>>>> Response.Write ("")
> >>>>>> Response.Write ("")
> >>>>>> Response.Write ("")
> >>>>>> Response.Write ("")
> >>>>>> Response.Write ("")
> >>>>>> Response.Write ("")
> >>>>>> 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" wrote in message
> >>>>>> news:%23H$G4kdCHHA.3836@TK2MSFTNGP02.phx.gbl...
> >>>>>>>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" wrote in message
> >>>>>>> news:hh57h.7074$0r.2737@newsread1.news.pas.earthlink.net...
> >>>>>>>> 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.
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>
> >>>
> >>
> >>
> >
> >
>
>

Re: Do While Loop nested in another While causes error

am 07.12.2006 04:19:11 von etm1109

May I suggest before you start your loop set your checking variable idHolder
= 0 or -1 or something you should not see in your data.
then in your loop:

if idHolder<>rsGuestbook("tblAlumniID") then
'do stuff here when I change guests
else
' don't do stuff same guest
end if
idHolder = rsGuestbook("tblAlumniID")

if your just wanting to pull several columns:
i.e.
guest number 1 hobbies: tennis
guest number 1 hobbies: cooking

you want to end up with :
guest number 1 hobbies: tennis cooking etc.

in the code I mentioned:
if idHolder<>rsGuestbook("tblAlumniID") then
'do stuff here when I change guests
if idHoldeer <> [my special value I set out of the loop] then
response.write "

"
end if
response.write ""
response.write ""
else
' don't do stuff same guest
response.write ""
end if
idHolder = rsGuestbook("tblAlumniID")

> >>>>>> color='#336633'>First Name: ")
> >>>>>> Response.Write(rsGuestbook("tblAlumniFirstName"))
> >>>>>> Response.Write ("
> >>>>>> color='#336633'>Last Name: ")
> >>>>>> Response.Write (rsGuestbook("tblAlumniLastName"))
> >>>>>> Response.Write ("
> >>>>>> color='#336633'>Maiden Name: ")
> >>>>>> Response.Write (rsGuestbook("tblAlumniMaidName"))
> >>>>>> Response.Write ("
Email:
> >>>>>>
")
> >>>>>> Response.Write (rsGuestbook("tblAlumniEmail"))
> >>>>>> Response.Write ("
Last
> >>>>>> Updated:
")
> >>>>>> Response.Write(rsGuestbook("tblAlumniDateUpdated"))
> >>>>>> Response.Write ("
> >>>>>>
align='center'>--------------------------------------------- ----------------
---")
> >>>>>> Response.Write ("
"& ... guest information...&"Hobbies:& rs("hobbies") & ""&rs("hobbies")& "