How count records without recordcount

Good evening.
In an Access Database, how do I count the records? If I write the following code it returns an error.


Var RecordFinder As RowSet
....
If RecordFinder <> nil and RecordFinder.RowCount > 0 then
.........
ERROR:
RowCount is not supported for this database

I have implemented the following code, is this whole round correct for counting records?

Dim i as integer=0
While Not RecordFinder.AfterLastRow
i=i+1
RecordFinder.MoveToNextRow
Wend
messagebox " Tot records: " + i.ToString 

I think you will need a SQL query:

SELECT Count(*) 
AS TotalOrders FROM Orders;
1 Like