When to use eof/bof movenext...do/loop...

Results 1 to 3 of 3

Thread: When to use eof/bof movenext...do/loop...

  1. #1
    JB Guest

    Default When to use eof/bof movenext...do/loop...

    Just wondering how I can learn when it&#039s best to use<BR><BR>eor/bof and what not to display records. I am not to familier on them and I am not quite sure what the benefits are.<BR><BR>I just want to know when to recognize a situation where I must have Rs.Eof and what not. Are there standard rules that apply, or tips? Such as:<BR><BR>"If you want to pull a record where id = form response, use X instead of Y"<BR><BR>Nothing urgent, I am just not familar with them and how they can benefit me as a programmer. Thanks<BR><BR>

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default RE: When to use eof/bof movenext...do/loop...

    Basically if you try and populate from a recordset which had NO records then you will getna error<BR><BR>usally this is what is done<BR><BR>while not rec.eof<BR>&#039populate here<BR>rec.movenext<BR>wend<BR><BR>this will populate all the records returned<BR><BR>or<BR>to make things more difficult<BR>rec.movelast<BR>while not rec.bof<BR>&#039populate here<BR>rec.moveprevious<BR>wend<BR><BR>what I do <BR><BR>while not rec.eof and not rec.bof<BR>&#039populate here<BR>rec.movenext<BR>wend<BR><BR><BR>another thing people do <BR><BR>if rec.eof then<BR> response.write "No records<BR>else<BR>&#039the loop here<BR>end if

  3. #3
    Join Date
    Dec 1969

    Default Why check both BOF and EOF???

    Akhilesh wrote:<BR><BR>*** QUOTE ***<BR>what I do <BR><BR>while not rec.eof and not rec.bof<BR>&#039populate here<BR>rec.movenext<BR>wend<BR>*** END QUOTE ***<BR><BR>Okay, Akhilesh, why???<BR><BR>The *ONLY* ways for BOF to be true are:<BR><BR>(1) You just did the query and there are no records in the recordset. In this case, *both* EOF and BOF are true. So testing for EOF is all you need. If it is true, so will BOF be. If it is false, so will BOF be.<BR><BR>(2) You are, indeed, going backwards through a RecordSet, using MovePrevious. If you are doing this, then EOF will *NEVER* be true, so you should only bother checking BOF. <BR><BR>But if you are using MoveNext, then BOF can never be true (except as noted in (1), above). <BR><BR>SO, in short, why?<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts