Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 12th, 2009, 03:19 PM
Authorized User
 
Join Date: Apr 2009
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Default problems with nested do while loop

I am trying to duplicate some one else's report with a web page. The report looks like an outline.
The way I have accomplished this it with a three deep nested Do While Loop and three recordsets here is the code;
Code:
If Recordset Then %>
    <table>
    <tr><th>Part Used</th><th>Symptom Code</th><th>Symptom Description</th><th>Part Notes</th><th>Total</th></tr>
<% Do While Not rs1.EOF %>
    <tr><td><%=rs1("replacementPartNumber") %>&nbsp;</td><td><%=rs1("description") %>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td><%=rs1("total") %>&nbsp;</td></tr>
 
    <%  
        Do While rs1("replacementPartNumber") = rs2("replacementPartNumber")%>
        <tr><td>&nbsp;</td><td><%=rs2("symptomCode") %>&nbsp;</td><td><%= rs2("sympDesc") %>&nbsp;</td><td>&nbsp;</td><td><%=rs2("test") %>&nbsp;</td></tr>
 
            <% 
            Do While rs2("symptomCode") = rs("symptomCode")
             %>
            <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td><%=rs("test2") %>&nbsp;</td><td><%=rs("test") %>&nbsp;</td></tr>
            <%rs.MoveNext
            Loop
            rs2.MoveNext 
        Loop
         rs1.MoveNext
    Loop
    rs1.MoveFirst %>
</table>
<%
rs.Close
rs1.Close
rs2.Close
Set rs = Nothing
Set rs1 = Nothing
Set rs2 = Nothing
End If
I tried to take out as much of the HTML style coding to make it easier to read.
My problem is that it runs and gives me the expected results except right above the table it displays an error message;

error '80020009'
/testdev/davie/davieworking/citizenPartUsageData.asp, line 71

line 71 is the inner most Do While statement.
If I remove the inner most Do While Loop the same error occurs at the "new" inner most loop.
Any help would be appreciated
Thanks
 
Old August 13th, 2009, 04:28 AM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default

My SQL is not great but where you have

Code:
Do While rs2("symptomCode") = rs("symptomCode")
You later have

Code:
rs.MoveNext
Loop
rs2.MoveNext 
Loop
but i can not see the
Code:
Do While rs
associated with the
Code:
rs.MoveNext Loop
I may be well off target but just a thought..

Cheers


Aspless
 
Old August 13th, 2009, 09:39 AM
Authorized User
 
Join Date: Apr 2009
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Default

The rs loop is the third or innermost loop. The Do While statement has the conditional statement rs2.("symptomCode") = rs("symptomCode") the code following uses the rs recordset the increments the cursor in rs and then checks the conditional statement again, then repeats until the symptomCode is different that is when the rs2 recordset increments. This is an example of the output.
The problem is even with eliminating the innermost loop (loop number 3) the error occurs in the NEW innermost loop (loop number 2)

DW24902-00 SHEET DIP SW (DW-10) 13
B01 VISUAL: BROKEN PART 4
N/A 4
P07 PRINT SEGMENT MISSNG 1
N/A 1
P08 PRINTHEAD BAD/BURN 1
N/A 1
U01 UPGRADED COMPONENT 7
N/A 7
N/A 2
 
Old November 12th, 2009, 05:00 PM
Authorized User
 
Join Date: Apr 2009
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Default

I endded up doing a work around, I loaded the recordsets into arrays and manipulated the arrays. Acheived the same results with out the error message.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested For-Each Loop In XSLT dghosh XSLT 10 July 2nd, 2008 04:34 AM
QueryTables nested loop Sherman McCoy Excel VBA 0 June 4th, 2008 02:37 PM
nested loop adnan2 Java Basics 1 July 13th, 2007 04:21 PM
Nested Do Until Loop goels Access VBA 2 September 30th, 2004 08:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.