Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help with nested while loop - classic ASP

    Hi,
    I have list of asp pages that are grouped together by sections they belong to - So section Add could have pages add.asp and add2.asp, section Delete could have pages del.asp and del2.asp so that the final display should look like this

    Click on link below:
    Add
    Add Item <- hyperlink to add.asp
    Add Item2 <- hyperlink to add2.asp

    Delete
    Delete Item <- hyperlink to del.asp
    Delete Item2 <- hyperlink to del2.asp

    The recordset returned by the query contains the following fields:
    Sections - The name of the section the page belongs to (Add, Delete)
    PagePath - The path to the page (http://localhost/test/add.asp)
    PageDescription - Description of page (Add Item, Delete Item)

    In the code below I get the following error when it comes out of the inner loop and goes back to the outer loop.
    Error Type: (0x80020009) Exception occurred.

    Any help to resolve this would be much appreciated. Thanks!

    Set objRS = Server.CreateObject("ADODB.Recordset")

    objRS.Open strQuery, strConnect, adOpenStatic, adLockOptimistic, adCmdText

    If Not objRS.EOF Then
    Response.Write "<br>Click on link below:<br><br>"
    objRS.MoveFirst

    While NOT objRS.EOF
    strSections = objRS("Sections")
    Response.Write objRS("Sections") & "<br>"

    While strSections = objRS("Sections")
    Response.Write "<a href=" & chr(34) & objRS("PagePath") & chr(34) & ">" & ObjRS("PageDescription") & "</a><br>"
    objRS.MoveNext
    Wend

    Wend

    objRS.Close
    Set objRS = Nothing
    End If

  • #2
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Figured it out

    I figured it out...here is the working code snippet

    If Not objRS.EOF Then
    Response.Write "<br>Click on link below:<br><br>"
    objRS.MoveFirst

    strSections = objRS("Sections")
    Response.Write "<b><u>" & strSections & "</u></b><br>"
    While NOT objRS.EOF
    If strSections = objRS("Sections") Then
    Response.Write "<li><a href=" & chr(34) & objRS("PagePath") & chr(34) & ">" & ObjRS("PageDescription") & "</a></li><br>"
    objRS.MoveNext
    Else
    If NOT objRS.EOF Then
    strSections = objRS("Sections")
    Response.Write "<b><u>" & strSections & "</u></b><br>"
    End If
    End If
    Wend

    objRS.Close
    Set objRS = Nothing
    End If


  •  

    Posting Permissions

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