gnewman
asked on
ODBC/CRecordset & Null characters
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?
Anyone know a fix for this?
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
May I ask you what you are trying to achieve with this technique ?