DFX_Text

void AFXAPI DFX_Text( CDaoFieldExchange* pFX, LPCTSTR szName, CString& value, int nPreAllocLength = AFX_DAO_TEXT_DEFAULT_SIZE, DWORD dwBindOptions = AFX_DAO_ENABLE_FIELD_CACHE );

Parameters

pFX

A pointer to an object of class CDaoFieldExchange. This object contains information to define the context for each call of the function. For more information about the operations a CDaoFieldExchange object can specify, see the article DAO Record Field Exchange: How DFX Works in Visual C++ Programmer’s Guide.

szName

The name of a data column.

value

The value stored in the indicated data member — the value to be transferred. For a transfer from recordset to data source, the value, of type CString, is taken from the specified data member. For a transfer from data source to recordset, the value is stored in the specified data member.

nPreAllocSize

The framework preallocates this amount of memory. If your data is larger, the framework will allocated more space as needed. For better performance, set this size to a value large enough to prevent reallocations.

dwBindOptions

An option that lets you take advantage of MFC’s double buffering mechanism for detecting recordset fields that have changed. The default, AFX_DAO_ENABLE_FIELD_CACHE, uses double buffering. The other possible value is AFX_DAO_DISABLE_FIELD_CACHE. If you specify this value, MFC does no checking on this field. You must call SetFieldDirty and SetFieldNull yourself.

These options are explained further in the article DAO Record Field Exchange: Double Buffering Records in Visual C++ Programmer's Guide.

Note   You can control whether data is double buffered by default by setting CDaoRecordset::m_bCheckCacheForDirtyFields.

Remarks

The DFX_Text function transfers CString data between the field data members of a CDaoRecordset object and columns of a record on the data source. Data is mapped between type DAO_CHAR in DAO (or, if the symbol _UNICODE is defined, DAO_WCHAR) and type CString in the recordset.

Example

This example shows several calls to DFX_Text. Notice also the two calls to CDaoFieldExchange::SetFieldType. ClassWizard normally writes the second call to SetFieldType and its associated DFX calls. You must write the first call and its DFX call. It is recommended that you put any parameter items before the “//{{AFX_FIELD_MAP” comment. You must put parameters outside the comments.

//Example for DFX_Text
void CSections::DoFieldExchange(CDaoFieldExchange* pFX)
{
    pFX->SetFieldType(CDaoFieldExchange::param);
    DFX_Text(pFX, "Name", m_strNameParam);
    //{{AFX_FIELD_MAP(CSections)
    pFX->SetFieldType(CDaoFieldExchange::outputColumn);
    DFX_Text(pFX, "CourseID", m_strCourseID);
    DFX_Text(pFX, "InstructorID", m_strInstructorID);
    DFX_Short(pFX, "LabFee", m_nRoomNo);
    DFX_Text(pFX, "LabFee", m_strSchedule);
    DFX_Short(pFX, "SectionNo", m_nSectionNo);
    DFX_Currency(pFX, "LabFee", m_currLabFee);
    //}}AFX_FIELD_MAP
}

See Also   DFX_Bool, DFX_Long, DFX_Currency, DFX_Short, DFX_Single, DFX_Double, DFX_DateTime, DFX_Byte, DFX_Binary, DFX_LongBinary, CDaoFieldExchange::SetFieldType