-
July 13th, 2012, 02:35 AM
#1
How to Retrive PDF Binary data from sqlserver
Dear All,
How to retrive PDF Binary data from sqlserver and save to PDF file using VC++ ?
our code is:
qry="select document from emptable where empno=1"//document field 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 and GetFieldValue() how can we retrive data?
Please give to us your suggestions.
Thank you,
medwrite.
-
July 15th, 2012, 05:44 AM
#2
Re: How to Retrive PDF Binary data from sqlserver
Why don't you use the overloaded CRecordset method
Code:
void GetFieldValue( LPCTSTR lpszName, CDBVariant& varValue, short nFieldType = DEFAULT_FIELD_TYPE );
throw( CDBException, CMemoryException );
Victor Nijegorodov
-
July 16th, 2012, 09:20 AM
#3
Re: How to Retrive PDF Binary data from sqlserver
Thank you for reply,
we have do as per your suggestion
GetFieldValue( LPCTSTR lpszName, CDBVariant& varValue, short nFieldType = DEFAULT_FIELD_TYPE );
CLongBinary* binarydata = varValue->m_pbinary;
But how to write a pdf file using this binary data ?
Please give to us your suggestions.
Thank you ,
Medwrite.
-
July 16th, 2012, 09:31 AM
#4
Re: How to Retrive PDF Binary data from sqlserver
Originally Posted by medwrite
... we have do as per your suggestion
GetFieldValue( LPCTSTR lpszName, CDBVariant& varValue, short nFieldType = DEFAULT_FIELD_TYPE );
CLongBinary* binarydata = varValue->m_pbinary;
But how to write a pdf file using this binary data ?
Please give to us your suggestions.
Sorry, but I have no idea what the relationship is between "pdf file" and some binary data read from SQL Server database.
What was the data saved as binary in database and what did it have to do with the .pdf file?
Victor Nijegorodov
-
July 18th, 2012, 01:13 PM
#5
Re: How to Retrive PDF Binary data from sqlserver
Originally Posted by medwrite
CLongBinary* binarydata = varValue->m_pbinary;
But how to write a pdf file using this binary data ?
Please give to us your suggestions.
I believe, the answer is pretty obvious. Did you bother to check CLongBinary documentation. HGLOBAL m_hData member contains data bytes handle, DWORD m_dwDataLength member contains bytes count. What is the problem here? You use GlobalLock function to access actual data bytes. And don't forget to unlock it later.
And I hope you know how to write memory buffer of known size to file.
Best regards,
Igor
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|