COleVariant::SetString

void SetString( LPCTSTR lpszSrc, VARTYPE vtSrc );

Parameters

lpszSrc

A null-terminated string to be copied into the new COleVariant object.

vtSrc   The VARTYPE for the new COleVariant object.

Remarks

Call this function to set the string to a particular type. The parameter vtSrc must be VT_BSTR (UNICODE) or VT_BSTRT (ANSI). SetString is typically used to set strings to ANSI, since the default for the COleVariant::COleVariant constructor with a string or string pointer parameter and no VARTYPE is UNICODE.

A DAO recordset in a non-UNICODE build expects strings to be ANSI. Thus, for DAO functions that use COleVariant objects, if you are not creating a UNICODE recordset, you must use the COleVariant::COleVariant( lpszSrc, vtSrc ) form of constructor with vtSrc set to VT_BSTRT (ANSI) or use SetString with vtSrc set to VT_BSTRT to make ANSI strings. For example, the CDAORecordset functions CDAORecordset::Seek and CDAORecordset::SetFieldValue use COleVariant objects as parameters. These objects must be ANSI if the DAO recordset is not UNICODE.

COleVariant OverviewClass MembersHierarchy Chart

See Also   COleVariant::COleVariant, CDAORecordset::Seek, CDAORecordset::SetFieldValue