How to Use EOF - end of file

  • I am trying to get the full name twice on a page. But for someone reason it only prints out one set of the data. Why?

    Is it due to the EOF being false. How do I solve this .?

    Regards

    ritesh

    <%do while not PreviewPage.EOF %>

     <% Response.write PreviewPage("FullName") %> <br>

     <%PreviewPage.movenext

        Loop  %>

     

    <%do while not PreviewPage.EOF %>

     <% Response.write PreviewPage("FullName") %> <br>

     <%PreviewPage.movenext

        Loop  %>

  • Are you trying to loop through the same recordset twice ?! If so, you'd have reached "EOF" the first time you loop through it!

    Why not just store the values in a variable and then use the variable ?!







    **ASCII stupid question, get a stupid ANSI !!!**

  • Hi,

    I am beginner at this so would you be able to point me in the correct direction to do this.

    Thanks

  • ritesh - it has been more than many months of sundays since I dealt with asp code...I can provide the logic...for syntax hopefully someone else will step in...

    1) dim an arrayvariable

    2) dim a counter

    3) In your "do while" loop...store the PreviewPage("FullName") value in your

    arrayvariable increasing the counter each time.

    4) the second time round when you have to display the names, loop through your

    array starting from 0 to UBound (????)

    btw..why do you have to display the names twice ?!







    **ASCII stupid question, get a stupid ANSI !!!**

  • I'm going to be creating a biography page. So at the top will be all of the names with a link when they click on the link it will scroll to the correct name and picture. So the name will need to be displayed twice.

     

  • You could try using PreviewPage.MoveFirst after the first loop to reset the pointer back to the beginning of the file.

    Another method is to use a bookmark (particulary useful if the starting point is not BOF):

    <%

      nBookmark = PreviewPage.Bookmark

      Do While Not PreviewPage.EOF

        Response.write PreviewPage("FullName") +"<br>"

        PreviewPage.movenext 

      Loop

      PreviewPage.Bookmark = nBookmark

    %>

     

  • your issue is that the first loop moves the data pointer to the end of the list (EOF) and you didn't reset it for the second loop.  Try something like this:

    <%do while not PreviewPage.EOF %>

     <% Response.write PreviewPage("FullName") %> <br>

     <%PreviewPage.movenext

        Loop  %>

    <% PreviewPage.MoveFirst %>

    <%do while not PreviewPage.EOF %>

     <% Response.write PreviewPage("FullName") %> <br>

     <%PreviewPage.movenext

        Loop  %>

    the MoveFirst should move the data pointer back to the beginning of the dataset.  as long as you haven't closed the dataset in the code between the two loops.  if you did close the dataset, you should move the close to after the second loop or you'll need to rerun the query.

  • read mkeast's first suggestion..







    **ASCII stupid question, get a stupid ANSI !!!**

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply