Infinate Loop Problem

Newbie Member
2Feb2010,19:26   #1
matthisco's Avatar
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
Light Poster
3Feb2010,00:11   #2
dennyphilip's Avatar
dude u have to advance the dr to the next item in the dataset else the loop becomes infinite
thus the page appears stuck... !!
Newbie Member
3Feb2010,15:13   #3
matthisco's Avatar
Thanks for you reply dude.

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