Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   Infinate Loop Problem (http://www.go4expert.com/forums/infinate-loop-problem-t20853/)

matthisco 2Feb2010 19:26

Infinate Loop Problem
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 3Feb2010 00:11

Re: Infinate Loop Problem
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 3Feb2010 15:13

Re: Infinate Loop Problem
Thanks for you reply dude.

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

All times are GMT +5.5. The time now is 02:01.