If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

You already call a rs.next() before the for loop and twenty times inside the loop [at the end]. In the last iteration, it will try to move to the 21st record and read it, which will result in the exception.

Another suggestion to you is that you should avoid using the count of records whenever possible. In your case, it is absolutely not necessary to do that way. You could always use a while loop with rs.next() and fetch all the records.

The reason for me to count the records was just a test for me. So i'd see how many records the SQL-query came up with. However It isn't resolved. But I think the problem is with the query itself! You ask for a top twenty, but I think here is the catch -> What happens if you have there are more results with the same criteria I mean:

position Name Time
1 Peter 0.30
2 Mark 0.45
2 Jim 0.45
3 Pim 0.48

If I make a SELECT TOP 2 * FROM table ORDER BY time what happens with the resultset? I know Access returns two, but what does the resultset do? Does it return three because positions 2 are the same? This could be it?

The TOP will select the topmost two, in your case.
1 Peter 0.30
2 Mark 0.45

Databases usually have their own way of internal ordering if the criterion for the ORDER BY clause generates matching columns. Even when the Time is same, Access will have it's own method of arranging the records which will be purely implementation specific. I guess it has something to do with the way records are stored internally.

When you specify a limiting condition to your query, the resultset will be similar to selecting the number of specified rows and ignoring the rest indiscriminately.