如何从sqlserver检索PDF二进制数据 [英] How to retrive PDF Binary data from sqlserver

查看:146
本文介绍了如何从sqlserver检索PDF二进制数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

如何使用VC ++从sqlserver检索PDF二进制数据并将其保存到PDF文件?

我们的代码是:

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 is image datatype
crs->Open(CRecordset::snapshot,qry,CRecordset::readOnly|CRecordset::executeDirect);

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


我们已经使用CString检索了二进制数据,但是当我们将这些数据写入PDF文件时,它将无法正常工作.

我们认为问题是CString,所以如果没有CString,我们该怎么办.
请给我们您的建议.

谢谢
raju.


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.

推荐答案

以与存储数据相同的方式读取数据.数据通常以VARIANT(或COleVariant)的形式提供.对于二进制数据(dbBinarydbLongBinary),变量类型为VT_ARRAY | VT_UI1.

将非变量类型传递给GetFieldValue()时,如果可能,数据将转换为目标类型.
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.


您已经获得了答案(实际上有1个以上)
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.


这篇关于如何从sqlserver检索PDF二进制数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆