Question:
When working with any IBX dataset component, why doesn't RecordCount return then number of records in my table on the server?

Answer:
The BDE called FetchAll before calling RecordCount, IBX datasets do not. Call TDataSet.FetchAll before using TDataSet.RecordCount. FetchAll actually downloads all the records locally and counts them, for large tables and result sets, this can be undesirable. A faster, server side way, of accomplishing the same task is to use two select statements:

IBQuery1.SQL.Clear;
IBQuery1.SQL.Add('select count(ANYFIELD) FROM YOURTABLE');
IBQuery1.Open;

You can access the RecordCount by

IBQuery1.FieldByName('COUNT').AsInteger;

5 Responses so far.

Post a Comment

Thank you for your comment.

Any request and idea are welcome.

CLICK TO REGISTER