Solved

DAO question

Posted on 1998-11-19
1
220 Views
Last Modified: 2013-11-20
OS: W95 - MSVC 4.0

I am going really crazy about that. I have a application which makes use of DAO to show and update a given database.
I had no experience to update/add records using DAO until
now - but i thought this couldn't be a problem.
That's where i went wrong - obviously BSTR isn't BSTR isn't
BSTR ...
When i try this:

COleVariant cVarField( <CString> );
pRecordset->SetFieldValue(1,cVarField);

I get a totally screwed up database. I took a look into the
VARIANT which is passed, and the 'bstrVal' member points
to a wide-character string. This seems to be the cause.
When i look at the VARIANT i get when fetching records, the
'bstrVal' then points to a simple zero-terminated string.
When i look into the documentation, i read 'BSTR is a length
prefixed string ...'.
I really don't want to build a workaround to that. I just
want to know how such a $!§"§$% can happen.

Thanks for a answer which explains this thing :)
0
Comment
Question by:snoegler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1324982
DAO through ACCESS appears to use ASCII BSTRs. It does NOT use UNICODE BSTRs. Almost every class that uses BSTRs assumes (correctly) BSTR is a pointer to a wide string. BUT, DAO uses BSTR as a pointer to an ASCII null-terminated string. Therefore, you cannot use any of the BSTR wrappers. You will need to write your own routines to extract and fill the VARIANT.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question