virtual BOOL Requery( );
throw( CDBException, CMemoryException );
Return Value
Nonzero if the recordset was successfully rebuilt; otherwise 0.
Remarks
Call this member function to rebuild (refresh) a recordset. If any records are returned, the first record becomes the current record.
In order for the recordset to reflect the additions and deletions that you or other users are making to the data source, you must rebuild the recordset by calling Requery. If the recordset is a dynaset, it automatically reflects updates that you or other users make to its existing records (but not additions). If the recordset is a snapshot, you must call Requery to reflect edits by other users as well as additions and deletions.
For either a dynaset or a snapshot, call Requery any time you want to rebuild the recordset using a new filter or sort, or new parameter values. Set the new filter or sort property by assigning new values to m_strFilter and m_strSort before calling Requery. Set new parameters by assigning new values to parameter data members before calling Requery. If the filter and sort strings are unchanged, you can reuse the query, which improves performance.
If the attempt to rebuild the recordset fails, the recordset is closed. Before you call Requery, you can determine whether the recordset can be requeried by calling the CanRestart member function. CanRestart does not guarantee that Requery will succeed.
Caution Call Requery only after you have called Open.
Example
This example rebuilds a recordset to apply a different sort order.
// Example for CRecordset::Requery
CCustSet rsCustSet( NULL );
// Open the recordset
rsCustSet.Open( );
// Use the recordset ...
// Set the sort order and Requery the recordset
rsCustSet.m_strSort = "District, Last_Name";
if( !rsCustSet.CanRestart( ) )
return; // Unable to requery
if( !rsCustSet.Requery( ) )
// Requery failed, so take action
CRecordset Overview | Class Members | Hierarchy Chart
See Also CRecordset::CanRestart, CRecordset::m_strFilter, CRecordset::m_strSort