The content CDaoRecordSet

  1. If the record set is derived from CDaoRecordSet, then GetRecordCount () function is useful, it always returns the total number of records. But, before calling GetRecordCount () function to ensure that you have had at least one CRecordSet MoveLast (). Otherwise, the total number of records returned is likely to be incorrect.
    2 , when the recording current is derived from CRecordSet then GetRecordCount () function is a substantially useless, it returns the total number of records is sometimes -1.
    3 , to get the total number of records, you can iterate over the record set, or a SQL statement.
    4 , VC ++ using the total number of records in an SQL statement to extract a bit of trouble, anyway, not as easy to Delphi, the preferred method j using ODBC API.
    5 , taken to traverse again set records, if the record set only five records say. If ninety million records, then iterate over the record set at least let users wait for dozens of minutes, or even hours, this method is impossible.

 

MoveNext can only be used to traverse the data record, or you use SQL statements to retrieve its data length, if you are using DAO, then you can directly get the number of records.

 

  1. GetRecordCount () function only in the use of MoveNext () function to traverse
    after all the records in the database, in order to get the correct result, therefore, the general
    is of no use, use 
    the while (! Rs.IsEOF ())
    {
     ....... ..
    }

    traverses the data records.

    2. Data records are not ordered by default, if
    you want to set the order, the use of m_strSort to the records
    sorted.

1 : need to MoveLast.
2 : need to MoveFirst.

Guess you like

Origin blog.csdn.net/thanklife/article/details/87938406