简体   繁体   English

如何使用VFP从SQL读取varbinary(max)字段值并将其另存为pdf?

[英]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.

相关问题 如何将html5画布图像保存到mssql varbinary(max)字段? - How to save a html5 canvas image to mssql varbinary(max) field? 如何在不更改值的情况下将数据从 nvarchar(max) 列移动到 SQL Server 中的 varbinary(max) 列? - How to move data from nvarchar(max) column to varbinary(max) column in SQL server without changing the value? 从SQL Server读取VARBINARY(MAX)到C# - Read VARBINARY(MAX) from SQL Server to C# 如何在VFP v8.0中基于另一个字段的最大值获取字段值 - How To Get A Field Value Based On The Max Of Another Field In VFP v8.0 SQL如何获取varbinary(max)的最大令牌? - SQL How to get max token of varbinary(max)? 使用ASP将SQL Server 2005中的varbinary PDF文件流式传输到浏览器 - stream varbinary PDF file from SQL 2005 to browser using ASP 使用来自VARBINARY(MAX)字段的Excel进行BULK INSERT - BULK INSERT with Excel from a VARBINARY(MAX) field SQL Server VARBINARY(最大) - SQL Server VARBINARY(MAX) SQL中的varbinary(max)错误 - varbinary(max) error in SQL 如何使用 SQL Server Reporting Services URL Access 将呈现的 PDF 报告作为 varbinary 保存到表中 - How to use SQL Server Reporting Services URL Access to save rendered PDF-Reports as varbinary into Table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM