Partilhar via


CDaoRecordset::GetRecordCount

Call this member function to find out how many records in a recordset have been accessed.

long GetRecordCount( );

Return Value

Returns the number of records accessed in a recordset object.

Remarks

GetRecordCount does not indicate how many records are contained in a dynaset-type or snapshot-type recordset until all records have been accessed. This member function call may take a significant amount of time to complete.

Once the last record has been accessed, the return value indicates the total number of undeleted records in the recordset. To force the last record to be accessed, call the MoveLast or FindLast member function for the recordset. You can also use a SQL Count to determine the approximate number of records your query will return.

As your application deletes records in a dynaset-type recordset, the return value of GetRecordCount decreases. However, records deleted by other users are not reflected by GetRecordCount until the current record is positioned to a deleted record. If you execute a transaction that affects the record count and subsequently roll back the transaction, GetRecordCount will not reflect the actual number of remaining records.

The value of GetRecordCount from a snapshot-type recordset is not affected by changes in the underlying tables.

The value of GetRecordCount from a table-type recordset reflects the approximate number of records in the table and is affected immediately as table records are added and deleted.

A recordset with no records returns a value of 0. When working with attached tables or ODBC databases, GetRecordCount always returns – 1. Calling the Requery member function on a recordset resets the value of GetRecordCount just as if the query were re-executed.

For related information, see the topic "RecordCount Property" in DAO Help.

Requirements

Header: afxdao.h

See Also

Reference

CDaoRecordset Class

Hierarchy Chart

CDaoRecordset::GetFieldCount

CDaoRecordset::GetFieldInfo

CDaoRecordset::GetIndexCount

CDaoRecordset::GetIndexInfo

Other Resources

CDaoRecordset Members