Поделиться через


CDaoRecordset::SetFieldValue

Call this member function to set the value of a field, either by ordinal position or by changing the value of the string.

virtual void SetFieldValue(
   LPCTSTR lpszName,
   const COleVariant& varValue 
);
virtual void SetFieldValue(
   int nIndex,
   const COleVariant& varValue 
);
void SetFieldValue(
   LPCTSTR lpszName,
   LPCTSTR lpszValue 
);
void SetFieldValue(
   int nIndex,
   LPCTSTR lpszValue 
);

Параметры

  • 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.

  • nIndex
    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.

Заметки

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, 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 related information, see the topics "Field Object" and "Value Property" in DAO Help.

Требования

Header: afxdao.h

См. также

Основные понятия

CDaoRecordset Class

CDaoRecordset Members

Hierarchy Chart

CDaoRecordset::GetFieldValue

CDaoRecordset::m_nParams

CDaoRecordset::SetFieldValueNull

COleVariant::COleVariant

COleVariant::SetString