Trailing nulls removed when retrieving SQL varbinary data through MFC/ODBC 
Author Message
 Trailing nulls removed when retrieving SQL varbinary data through MFC/ODBC

I've got an MFC app using ODBC which is storing and retrieving data in a
varbinary(255) field in an MS SQL Server database. If there are
zero-value bytes at the end of the data, I find them removed on
retrieval (they ARE successfully stored). I want those bytes!

Some info that might be relevant:
* The MS SQL Server version is 6.5.
* The SQL Server ODBC driver (sqlsrv32.dll) version is 2.65.0240.
* The driver is configured with "Use ANSI Nulls, Padding and Warnings"
  checked on.
* The ODBC version is 3.0.28.22.
* The VC++/MFC version is 5.

Also...
* The app's DB code is CRecordset-derived, and Class Wizard-generated.
  The column is bound to a CByteArray data member.
* The same code run against an Access DB (using a Text field) works
  fine; the nulls are preserved.
* MSQuery retrieves the data correctly. I was thinking that there was
  a problem with the SQL Server driver, but this disproves that (I
  think), or at least shows that it can be dealt with. (Assuming that
  MSQuery is using the same ODBC code--which it is, as far as I can
  tell.)

Please help!
Thank you, Dave



Sun, 19 Mar 2000 03:00:00 GMT  
 Trailing nulls removed when retrieving SQL varbinary data through MFC/ODBC

Do you load the cursor library? I seem to recall observing this exact same
behavior, but it changed depending on whether I was using client or server
cursors. (Sorry, but I don't remember which cursor type produced the
symptom).

--
Randy Baker (remove Z from address in email replies)



Quote:
> I've got an MFC app using ODBC which is storing and retrieving data in a
> varbinary(255) field in an MS SQL Server database. If there are
> zero-value bytes at the end of the data, I find them removed on
> retrieval (they ARE successfully stored). I want those bytes!

> Some info that might be relevant:
> * The MS SQL Server version is 6.5.
> * The SQL Server ODBC driver (sqlsrv32.dll) version is 2.65.0240.
> * The driver is configured with "Use ANSI Nulls, Padding and Warnings"
>   checked on.
> * The ODBC version is 3.0.28.22.
> * The VC++/MFC version is 5.

> Also...
> * The app's DB code is CRecordset-derived, and Class Wizard-generated.
>   The column is bound to a CByteArray data member.
> * The same code run against an Access DB (using a Text field) works
>   fine; the nulls are preserved.
> * MSQuery retrieves the data correctly. I was thinking that there was
>   a problem with the SQL Server driver, but this disproves that (I
>   think), or at least shows that it can be dealt with. (Assuming that
>   MSQuery is using the same ODBC code--which it is, as far as I can
>   tell.)

> Please help!
> Thank you, Dave



Mon, 20 Mar 2000 03:00:00 GMT  
 Trailing nulls removed when retrieving SQL varbinary data through MFC/ODBC

Randys, thanks for your response.

I tried opening the CDatabase with bUseCursorLib set to TRUE and to
FALSE and I got the same result in both cases. Any other ideas?

Thanks, Dave

Quote:

> Do you load the cursor library? I seem to recall observing this exact same
> behavior, but it changed depending on whether I was using client or server
> cursors. (Sorry, but I don't remember which cursor type produced the
> symptom).

> --
> Randy Baker (remove Z from address in email replies)



> > I've got an MFC app using ODBC which is storing and retrieving data in a
> > varbinary(255) field in an MS SQL Server database. If there are
> > zero-value bytes at the end of the data, I find them removed on
> > retrieval (they ARE successfully stored). I want those bytes!

> > Some info that might be relevant:
> > * The MS SQL Server version is 6.5.
> > * The SQL Server ODBC driver (sqlsrv32.dll) version is 2.65.0240.
> > * The driver is configured with "Use ANSI Nulls, Padding and Warnings"
> >   checked on.
> > * The ODBC version is 3.0.28.22.
> > * The VC++/MFC version is 5.

> > Also...
> > * The app's DB code is CRecordset-derived, and Class Wizard-generated.
> >   The column is bound to a CByteArray data member.
> > * The same code run against an Access DB (using a Text field) works
> >   fine; the nulls are preserved.
> > * MSQuery retrieves the data correctly. I was thinking that there was
> >   a problem with the SQL Server driver, but this disproves that (I
> >   think), or at least shows that it can be dealt with. (Assuming that
> >   MSQuery is using the same ODBC code--which it is, as far as I can
> >   tell.)

> > Please help!
> > Thank you, Dave



Tue, 21 Mar 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. MFC ODBC NULL/NOT NULL

2. How to pass NULL params in RFX for CRecordset in SQL Server/ODBC

3. Detecting SQL NULL values from ODBC

4. How to pass NULL params in RFX for CRecordset in SQL Server/ODBC

5. retrieve XML data from SQL server by using XSD mapping schema

6. How Retrieving SQL Server Binary Data

7. Retrieving SQL Server Binary Data

8. Varbinary sql output parameter to byte[]

9. ODBC API, SQL_C_DATE - how to retrieve field data?

10. I want to use COM for retrieving data from ODBC

11. Help needed: problem in using odbc call to write binary data to SQL Server

12. retrieving ODBC unicode database records in MFC

 

 
Powered by phpBB® Forum Software