virtual void DoFieldExchange( CFieldExchange* pFX );
throw( CDBException );
Parameters
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.
Remarks
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) in Visual C++ Programmer’s Guide.
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)
{
//{{AFX_FIELD_MAP(CCustSet)
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Text(pFX, "Name", m_strName);
RFX_Int(pFX, "Age", m_wAge);
//}}AFX_FIELD_MAP
}
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. Both articles are in Visual C++ Programmer’s Guide.
CRecordset Overview | Class Members | Hierarchy Chart
See Also CRecordset::m_nFields, CRecordset::m_nParams, CRecordset::DoBulkFieldExchange, CRecordset::GetFieldValue, CFieldExchange, Record Field Exchange Functions