Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using RecordCount Property of DataSet

Status
Not open for further replies.

Delphard

Programmer
Jul 22, 2004
144
0
0
RS
Marco Cantu in his "Delphi 2005" book says that using RecordCount property means that all Records will be re-loaded on client. Is that true?
 
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

Steven
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top