[thelist] ASP/TSQL/UID

Chris Marsh chris at webbtech.co.uk
Wed Oct 2 11:58:01 CDT 2002


> > With ADO to test for an empty record set you check to see
> > if the record set is at the begining and the end
> simultaneously. That
> > condition is only true for empty record sets.
>
> Yes, but doing so is often unnecessary in practice, because
> if a recordset is empty then EOF will always be true anyway
> -- so a construction like If Not (rs.EOF And rs.BOF) Then
>   Do While Not rs.EOF
>     ...
>   Loop
> End If
>
> Is functionally exactly equivalent to
> Do While Not rs.EOF
>   ...
> Loop
>
> The only time I can see checking both BOF and EOF is if you
> for some reason need to report that no rows were returned.

This was what I was testing for. The reason that the While statement is
within a conditional is that you only check once to see if no rows were
returned, therefore giving a very slight performance gain on checking
BOF and EOF every time the loop executes. The reason that I don't simply
check for EOF is probably mere pedantry on my part, but I try to keep
things technically correct for ease of future editing and to keep me
away from embracing bad habits.

Regards

Chris Marsh





More information about the thelist mailing list