Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Dear All,

How to retrive PDF Binary data from sqlserver and save to PDF file using VC++ ?

our code is:

C++
qry="select document from  emptable where empno=1"; //document is image datatype
crs->Open(CRecordset::snapshot,qry,CRecordset::readOnly|CRecordset::executeDirect);

                 while(!crs->IsEOF())
		    {
			crs->GetFieldValue("document",strDocument);
						
		     }

we have retrive binary data using CString but when we write this data into a PDF file it is NOT working.

we think the problem is CString So without CString how can we do.
Please give to us your suggestions.

Thank you,
raju.
Posted
Updated 12-Jul-12 2:18am
v2

Read the data in the same way as they are stored. Data are usually provided as VARIANT (or COleVariant). With binary data (dbBinary and dbLongBinary) the variant type is VT_ARRAY | VT_UI1.

When passing non-variant types to GetFieldValue(), data are converted to the destination type if possible.
 
Share this answer
 
You have already been given the answer (more than 1 in fact) here[^]. Do not convert file contents to CStrings unless you know that the data is pure text. And even if you do know that, it is not a sensible idea. Spend some time studying file handling in computers and how to manage binary data.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900