Error In code - Do Loop

J

JP SIngh

I trying to print the name of all the lists and the members of those list.
The code below works perfectly but it gives an error on the last listname

error '80020009'
/addeditdependentlists.asp, line 278

Can someone please help. The solution I have implemented is from the answer
provided by Phil W in my question "Basic Looping Question" on 3rd AUg 2005
at 11:59

thanks

<% strSQL = "SELECT DependentLists.id, DependentLists.ListName,
EMPProfile.Firstname, EMPProfile.Lastname "
strSQL = strSQL & " FROM (DependentLists LEFT JOIN
DependentListMembers ON DependentLists.Id=DependentListMembers.ListId) LEFT
JOIN EMPProfile ON DependentListMembers.Empname=EMPProfile.EmpName "
strSQL = strSQL & " ORDER BY DependentLists.ListName,
EMPProfile.Firstname; "

Set RSV = Server.CreateObject("ADODB.Recordset")
RSV.Open strSQL, conn, adOpenForwardOnly, adLockReadOnly, adCmdText
Do While Not RSV.EOF
prlistname = rsv("listname")
%>

<tr>
<td><%=rsv("ListName")%></td>
<td>
<table>

<%do while not rsv.eof and rsv("listname") = prlistname%> ' ******** THIS
IS THE LINE (278)

<tr>
<td><font face="Arial" size="2"><%=rsv("Lastname") & " " &
rsv("firstname")%></font></td>
</tr>
<%
rsv.movenext
Loop

%>
</table>
</td>

</tr>
<%
RSV.MoveNext
Loop

%>
</tbody>
</table>
<%
RSV.Close
Set RSV = Nothing
%>
 
P

Phill. W

JP SIngh said:
I trying to print the name of all the lists and the members of those list.
The code below works perfectly but it gives an error on the last listname

error '80020009'
/addeditdependentlists.asp, line 278

Can someone please help.
The solution I have implemented is from the answer provided by Phil W

And I *apologise* for giving you Bad Code.

<excuse>I've been contaminated by .Net lately and forgot that
VBScript doesn't "short-circuit" If statements. </excuse>

You're problem is that when you hit the end of the recordset, you
/can't/ access any of the /items/ in the row, because there's no current
row any more!

This might work a little better :

Do While Not rsv.EOF
prlistname = rsv("listname")

Do While Not rsv.EOF
If prlistname <> rsv("listname") Then
' output List
entry

prlistname = rsv("listname")
End If

' output member entry

. . .
rsv.MoveNext
Loop
Loop

HTH,
Phill W.​
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top