Solved

ODBC/CRecordset & Null characters

Posted on 1997-03-24
4
257 Views
Last Modified: 2013-11-20
MS Access has no trouble allowing the null character in a text field, and MS C++ has no trouble allowing the null character in a CString.  However, when I construct a CString with the null character in the middle, CString("Hi\0Joe",7) and then use AddNew to write that field into an Access database text field, the string gets truncated at the \0.

Anyone know a fix for this?
0
Comment
Question by:gnewman
  • 2
4 Comments
 
LVL 4

Expert Comment

by:mbhakta
Comment Utility
There are several reasons why this is happening. One of the major reasons is your CString is nothing but an internal typecast of LPCSTR. A '\0' indicates a null termination and end of string. Hence, the problem.

May I ask you what you are trying to achieve with this technique ?
0
 

Author Comment

by:gnewman
Comment Utility
In your DoDataExchange function use RFX_Binary() rather than RFX_Text().  RFX_Binary requires a parameter of type CByteArray&, so either convert your CString to a CByteArray or use CByteArray to manipulate your strings rather than CString.
0
 
LVL 1

Accepted Solution

by:
rhgaracci earned 70 total points
Comment Utility
Will RFX_Binary() work if the field type in the database table is text?  I'm under the impression that it only works if the field type is VARBINARY which I can't create in MS-Acess 2.0
0
 

Author Comment

by:gnewman
Comment Utility
It should work as ODBC supports conversions between all character types and SQL_VARBINARY.  Try it.  If it doesn't work the way you want, you may need to make your own RFX_ function.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

10 Experts available now in Live!

Get 1:1 Help Now