[英]How to read the varbinary (max) field value from SQL using VFP and Save it as pdf?
I am connecting my vfp applcication with SQL server. 我正在将vfp应用程序与SQL Server连接。 One table having the varbinary field and I need to read the binary and convert that into pdf file .
一个具有varbinary字段的表,我需要读取二进制文件并将其转换为pdf文件。 How I can do that ?
我该怎么做?
Do you mean that the varbinary data itself is a PDF file (or any file)? 您是说varbinary数据本身就是PDF文件(或任何文件)吗? If so just save the bytes you get to a file with a .PDF extension.
如果是这样,只需保存字节,您就可以得到扩展名为.PDF的文件。 ie:
即:
Let's assume you have a table named "Files" in database "test" with fields like Id, FileExt and FileContent. 假设您在数据库“ test”中有一个名为“ Files”的表,其中包含Id,FileExt和FileContent等字段。 FileExt holding the extension and FileContent is the file itself as varbinary(Max).
保留扩展名的FileExt和FileContent是文件本身,为varbinary(Max)。 You want to save all files to a folder named 'c:\\temp\\files':
您要将所有文件保存到名为“ c:\\ temp \\ files”的文件夹中:
Local handle, filename
handle = Sqlstringconnect("driver={Sql Server Native Client 11.0};server=.\SQLExpress;Database=test;Trusted_Connection=yes")
SQLExec(m.handle, 'Select * from [Files]', 'crsData')
SQLDisconnect(m.handle)
Select crsData
Scan
fileName = Forcepath(Forceext(Ltrim(Str(crsData.Id)),Trim(crsData.FileExt)))
Strtofile(crsData.FileContent, m.fileName, 'c:\temp\files')
Endscan
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.