This example uses the BOF and EOF properties to find the beginning and end of an Orders table. The example moves through the records from the beginning of the file to the end and then from the end to the beginning. Notice that there is no current record immediately following the first loop.
CdbDBEngine dbeng;
CdbDatabase dbsNorthwind;
CdbRecordset rstOrders;
dbsNorthwind = dbeng.OpenDatabase(_T("Northwind.mdb"));
rstOrders = dbsNorthwind.OpenRecordset(_T("Orders")); //open RS
while (!rstOrders.GetEOF()) // loop through all records
{
// DO SOMETHING WITH THE RECORD
rstOrders.MoveNext(); // move to the next record
}
rstOrders.MoveLast(); // move to the last record
while (!rstOrders.GetBOF()) // loop through all records
{
// DO SOMETHING WITH THE RECORD
rstOrders.MovePrevious(); // move to the previous record
}
rstOrders.Close();
dbsNorthwind.Close();