CRecordset GetRecordCount
-
Ive found myself on more than one ocassion writing code in MFC which imlements a database query using a CRecordset, and churns through the records one at a time doing something to each record. This type of operation is typically time consuming, and therefore I would like to present the user with a percentage complete indicator (Progress Bar). My problem of course is that I dont know the size of the record set a priori (GetRecordCount returns only the highest numbered record so far accessed). Of course I dont want to churn thru the record set before hand to determine its size. Any ideas on an elegant way to attack this? Other ways to produce satisfactory progress feedback to the user? Thanks very much in advance! :) Dave Carkeet, Santiago, Chile
-
Ive found myself on more than one ocassion writing code in MFC which imlements a database query using a CRecordset, and churns through the records one at a time doing something to each record. This type of operation is typically time consuming, and therefore I would like to present the user with a percentage complete indicator (Progress Bar). My problem of course is that I dont know the size of the record set a priori (GetRecordCount returns only the highest numbered record so far accessed). Of course I dont want to churn thru the record set before hand to determine its size. Any ideas on an elegant way to attack this? Other ways to produce satisfactory progress feedback to the user? Thanks very much in advance! :) Dave Carkeet, Santiago, Chile
Ok, so MoveLast before GetRecordCount is not an option. Seems that percentage is absolutely necessary you need to perform query with 'SELECT COUNT(*)' and identical WHERE clause before traversing the recordset. Of course, number of records could change between two queries in multi-user scenario, so value returned from first query should be treated with care. COUNT(*) can also be pretty expensive, depending on WHERE. I don't know your exact requirements, but maybe it's enough to just display a message like 'Please wait, processed 19002 records so far...'. Tomasz Sowinski -- http://www.shooltz.com.pl