Solved

DAO question

Posted on 1998-11-19
1
216 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
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

839 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