This documentation is archived and is not being maintained.


Called to exchange data (in both directions) between the field data members of the recordset and the corresponding record on the data source. Implements record field exchange (RFX).

virtual void DoFieldExchange(
   CFieldExchange* pFX 


A pointer to a CFieldExchange object. The framework will already have set up this object to specify a context for the field exchange operation.


When bulk row fetching is not implemented, the framework calls this member function to automatically exchange data between the field data members of your recordset object and the corresponding columns of the current record on the data source. DoFieldExchange also binds your parameter data members, if any, to parameter placeholders in the SQL statement string for the recordset's selection.

If bulk row fetching is implemented, the framework calls DoBulkFieldExchange. To implement bulk row fetching, you must specify the CRecordset::useMultiRowFetch option of the dwOptions parameter in the Open member function.

Note   DoFieldExchange is available only if you are using a class derived from CRecordset. If you have created a recordset object directly from CRecordset, you must call the GetFieldValue member function to retrieve data.

The exchange of field data, called record field exchange (RFX), works in both directions: from the recordset object's field data members to the fields of the record on the data source, and from the record on the data source to the recordset object.

The only action you must normally take to implement DoFieldExchange for your derived recordset class is to create the class with ClassWizard and specify the names and data types of the field data members. You might also add code to what ClassWizard writes to specify parameter data members or to deal with any columns you bind dynamically. For more information, see the article Recordset: Dynamically Binding Data Columns (ODBC).

When you declare your derived recordset class with ClassWizard, the wizard writes an override of DoFieldExchange for you, which resembles the following example:

void CCustSet::DoFieldExchange(CFieldExchange* pFX)
   RFX_Text(pFX, "Name", m_strName);
   RFX_Int(pFX, "Age", m_wAge);

For more information about the RFX functions, see the topic Record Field Exchange Functions.

For further examples and details about DoFieldExchange, see the article Record Field Exchange: How RFX Works. For general information about RFX, see the article Record Field Exchange.


This method can throw exceptions of type CDBException*.

See Also

CRecordset Overview | Class Members | Hierarchy Chart | CRecordset::m_nFields | CRecordset::m_nParams | CRecordset::DoBulkFieldExchange | CRecordset::GetFieldValue | CFieldExchange | Record Field Exchange Functions