SQL Query question

Status
Not open for further replies.

CuriouslySane

Ars Praefectus
4,224
Subscriptor
Is it necessary to surrond that while loop in that if statement? Isn't it true that if Query.EOF is true that it won't enter the loop anyway?

The surrounding 'if' is redundant unless MrCatbert intended to insert some initialization before the loop, conditional on the cursor not being empty. (If, for example, an initial 'Query.MoveNext' is required to position the cursor on the first row.)
 

MrCatbert

Ars Tribunus Angusticlavius
9,107
Subscriptor
If you perform the while loop without checking the state of the data first with the if statement, your asp page is going to kick back an error rather than continuing to process the page if the dataset is empty...

[Edit]Sorry, I didn't read CurioslySane's post closely enough. Typically you do a MoveFirst before you start the While loop, and THAT will kick back the error if you haven't checked for an empty dataset. I usually do the if ... .EOF right after I've pulled the data through the SELECT statement then process the rest of the page conditionally.
 
Status
Not open for further replies.