Article ID: 140599 - Last Review: November 21, 2006 - Revision: 3.1 PRB: MFC DAO Functions Accepting COleVariant Strings May FailThis article was previously published under Q140599 SYMPTOMS
The MFC DAO Classes contain methods that accept COleVariant arguments. For
example, CDaoRecordset::Seek(), CDaoRecordset::SetFieldValue(), and
CDaoRecordset::SetBookMark() accept COleVariant arguments. You may find
that these functions do not perform correctly if you are building a
non-UNICODE build of your application and you are assigning a string to a
COleVariant and passing the variant to one of these methods. For example, look at the following code, which is shown in MFC Technote #53: CAUSE
MFC creates ANSI DAO objects when building non-UNICODE builds and creates
UNICODE DAO objects when building UNICODE builds. For example, look at the
following code in AfxDaoInit():
RESOLUTION
There are two techniques you can use to initialize the COleVariant
properly. If you are only concerned about setting the BSTR value of the
COleVariant at construction time, use this code:
If you need to change the value of the variant often, you may want to create a helper function: STATUS
This behavior is by design.
APPLIES TO
| Article Translations
|
Back to the top
