Requery Method

See Also      Applies To

Updates the data in a CdbRecordset object by re-executing the query on which the object is based.

Syntax

VOIDRequery(CdbQueryDef *pq = NULL);

Parameters

Type Argument Description
CdbQueryDef * pq Optional. Pointer to a CdbQueryDef object (Microsoft Jet workspaces only).

Remarks

Use this method to make sure that a CdbRecordset contains the most recent data. This method re-populates the current CdbRecordset by using either the current query parameters or (in a Microsoft Jet workspace) the new ones supplied by the pg argument.

In an ODBCDirect workspace, if the original query was asynchronous, then Requery will also execute an asynchronous query.

If you don't specify a pg argument, the CdbRecordset is re-populated based on the same query definition and parameters used to originally populate the CdbRecordset. Any changes to the underlying data will be reflected during this re-population. If you didn't use a QueryDef to create the CdbRecordset, the CdbRecordset is re-created from scratch.

If you specify the original CdbQueryDef in the pg argument, then the CdbRecordset is requeried using the parameters specified by the CdbQueryDef. Any changes to the underlying data will be reflected during this re-population. To reflect any changes to the query parameter values in the CdbRecordset, you must supply the pgf argument.

If you specify a different CdbQueryDef than what was originally used to create the CdbRecordset, the CdbRecordset is re-created from scratch.

When you use Requery, the first record in the CdbRecordset becomes the current record.

You can't use the Requery method on dynaset- or snapshot-type CdbRecordset objects whose Restartable property is set to False. However, if you supply the optional pg argument, the Restartable property is ignored.

If both the BOF and EOF property settings of the CdbRecordset object are True after you use the Requery method, the query didn't return any records and the CdbRecordset contains no data.

Usage

#include <afxole.h>
#include <dbdao.h>

CdbRecordset recordset;
...
recordset.Edit();         // Make some changes
...
recordset.Update;         // Save changes
recordset.Requery();     // Refresh the recordset