1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Infinate Loop Problem

Discussion in 'Visual Basic ( VB )' started by matthisco, Feb 2, 2010.

  1. matthisco

    matthisco New Member

    Joined:
    Feb 2, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi Folks,

    I'm trying to loop through my query results using datareader.

    I want to create a submenu by checking the subtitle exists then concatenate the values.


    1. while (reader.Item("subtitle").tostring() <> "")
    2. submenu &= "<p>" & reader.Item("subtitle") & "</p>"
    3. end while

    The page wont seem to load though, it must be a problem with the loop, do you know how I can read the next item?

    Here is my comlpete code:

    Code:
    While reader.Read()
    
    ' set title
    
    sitename =  reader.Item("sitename")
    
    
    mydata &= "<p>" &  reader.Item("pagetitle") & "</p>"
    
    
    'check for subpages then create submenu
    
        if  (reader.Item("subtitle").tostring() <> "")
    
    
        while  (reader.Item("subtitle").tostring() <> "")
    
        submenu  &= "<p>" & reader.Item("subtitle") & "</p>"
    
         end while
    
    'concatenate submenu to main data
    
        mydata &= submenu
    
        End if
             
    End while
     
  2. dennyphilip

    dennyphilip New Member

    Joined:
    Oct 18, 2009
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    bengaluru
    dude u have to advance the dr to the next item in the dataset else the loop becomes infinite
    thus the page appears stuck... !!
     
  3. matthisco

    matthisco New Member

    Joined:
    Feb 2, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for you reply dude.

    Could you please tell me how I can advance the loop?
     

Share This Page