Hi.
The Recordcount function is not failsafe, just like Marco says.
There are several problems using RecordCount, and I have stopped using it just because you cannot be sure if the result is correct.
I would use if EOF or not EOF to check if I have data.
If I want to get the number of rows, which can fool recordcount, insert the data into a temptable (SELECT * INTO #TempTable) and then use SELECT COUNT(*) FROM #TempTable to get the number of rows. In most cases, you want to use the recordset anyway, so why not store them into a temptable before using the recordset?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-"There is always another way to solve it, but I prefer my way.
The recordcount property will work with objects that make use of the BDE. I found out that with Interbase objects (when upscaling after a test with Paradox) the results are unpredictable.
The workaround:
Code:
Query1.Open;
Query1.FetchAll;
// rest of programming stuff...
makes recordcount available, handy if you want to load stuff from tables in listboxes, checklistboxes or string grids
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.