CDaoRecordset::SetFieldValue

void SetFieldValue( LPCTSTR lpszName, const COleVariant& varValue );
throw( CDaoException, CMemoryException );

void SetFieldValue( int nOrdinal, const COleVariant& varValue );
throw( CDaoException, CMemoryException );

void SetFieldValue( LPCTSTR lpszName, LPCTSTR lpszValue );

void SetFieldValue( int nOrdinal, LPCTSTR lpszValue );

Parameters

lpszName

A pointer to a string containing the name of a field.

varValue

A reference to a COleVariant object containing the value of the field’s contents.

nOrdinal

An integer that represents the ordinal position of the field in the recordset’s Fields collection (zero-based).

lpszValue

A pointer to a string containing the value of the field's contents.

Remarks

Call this member function to set the value of a field, either by ordinal position or by changing the value of the string. Use SetFieldValue and GetFieldValue to dynamically bind fields at run time rather than statically binding columns using the DoFieldExchange mechanism.

Note that if you are not creating a UNICODE recordset, you must either use a form of SetFieldValue that does not contain a COleVariant parameter (one of the last two syntax forms), or the COleVariant object must be explicitly declared ANSI. This can be done by using the COleVariant::COleVariant( lpszSrc, vtSrc ) form of constructor with vtSrc set to VT_BSTRT (ANSI) or by using the COleVariant function SetString( lpszSrc, vtSrc ) with vtSrc set to VT_BSTRT.

For more information about record field exchange, see the articles DAO Record Field Exchange (DFX) and DAO Recordset: Binding Records Dynamically in Visual C++ Programmer's Guide. For related information, see the topics "Field Object" and "Value Property" in DAO Help.

CDaoRecordset OverviewClass MembersHierarchy Chart

See Also   CDaoRecordset::GetFieldValue, CDaoRecordset::m_nParams, CDaoRecordset::SetFieldValueNull, COleVariant::COleVariant, COleVariant::SetString