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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number of Items in a Table

Status
Not open for further replies.

tjc240e

Technical User
Nov 12, 2004
133
US
Would the best way to find how many items there are in a table be just go through with a while do loop or is there an easier way?

TIA
 

What kind of table?

Database: SELECT COUNT(*) FROM ATABLE

TStringGrid: MyGrid.RowCount - MyGrid.FixedRows

TDBGrid: There is a property, but accessing it may cause all of the records to be read, hurting performance. May be best to use the SELECT COUNT(*) technique.

 

Sorry, not familiar with that. But if it descends from TDataSet, there should be a .RecordCount property.

If you experience performance problems, try experimenting with client-side vs server-side result sets.

using a TQuery with SELECT COUNT(*) should work in any case.

 
if the table is already loaded in a Ttable..

u could also use

Table1.RecordCount

jb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top