How to get number of records in the database using recordset
This is a real simple problem but for some reason I haven't been able to figure it out. I am executing a query and I need to get the number of records returned from the query and need to use that number to loop through some operations. I have tried rs.RecordCount where rs is a recordset but receive a -1. What is the function to get the number of rows returned?
Munir ShaikhPosted Aug 1, 2007, 6:35 AM
Jan MontanoPosted Jun 1, 2007, 1:47 AM
SELECT count(*) from myTable. then execute your real query.
or in your query for example, SELECT field1,field2 from myTable, you could modify it instead to select count(field1),field1,field2 from myTable so that it will be only one call. Implementation is up to you.
I normally would query it twice. First for the count. then for the actual data. Cheers!