Infinate Loop Problem

matthisco's Avatar, Join Date: Feb 2010
Newbie Member
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:

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
dennyphilip's Avatar, Join Date: Oct 2009
Light Poster
dude u have to advance the dr to the next item in the dataset else the loop becomes infinite
thus the page appears stuck... !!
matthisco's Avatar, Join Date: Feb 2010
Newbie Member
Thanks for you reply dude.

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