Solved

DAO question

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 101
How do you programatically show and hide the Windows 10 On-Screen-Keyboard? 3 680
zeroMAx challenge 20 105
fix34  challenge 9 123
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.

831 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