Solved

ODBC/CRecordset & Null characters

Posted on 1997-03-24
4
258 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
ID: 1300637
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
ID: 1300639
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
ID: 1300640
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
ID: 1300641
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 90
Prevent this page from creating additional dialogs. 3 385
either24  challenge 19 90
Change to event 1 99
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: 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…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

937 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

4 Experts available now in Live!

Get 1:1 Help Now