Solved

DAO question

Posted on 1998-11-19
1
213 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 21
Looking for a specific application/software 2 91
EvenOdd challenge 10 83
FizzBuzz challenge 9 73
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now