Actually you can add that condition to your DO WHILE itself. No need of IF there. The problem with the IF condition as given in my previous post is, even after reaching the EOF, untill VARCOUNT becomes > than PAGESIZE, it would loop through unnecessarily. As in your case the PAGESIZE is 5, one would not see any big effect. When it is changed to a bigger value, it could affect the performance. To avoid that you may check for NOT EOF in DO WHILE itself.
Do while varCount <= rsData.pageSize and NOT rsData.EOF
...
...
...
rsData.MoveNext
loop
Cheers!
-Vijay G
|