John Smith wrote:
I'm trying to perform a loop to display the contents of my DB, the
only issue is that I would only like to display 10 results maximum
this is relatively easy but what happens if there are less than 10
results in the DB. If I was going to do a :
Do Until objRS.EOF
Then it would display the full records, likewise if i put a counter
on the loop then it will run into errors if I have less records than
the count.......
ideas ?
thanks.
What database?
With Access and SQL Server, you can use the TOP n construct in your query to
limit the records returned (SELECT TOP 10 <field list> FROM table ...). With
SQL Server, you can also use SET ROWCOUNT to do the same thing.
If you have an antique database that does not support TOP, then simply
combine your counter idea with your DO loop:
dim i
i = 0
Do Until rs.eof OR i = 10
....
i = i + 1
rs.movenext
loop
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"