vba - 将 pdf 文件插入 SQL Server 链接数据库
问题描述
我是 Access 编程新手,尝试将.pdf
Word 文档插入 SQL Server 链接数据库并遇到问题。我需要一些提示才能开始。可以帮忙。
Dim f As Object
Dim sFile As String
Dim fld_path As String
Dim fld_file As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim Sql As String
Dim Code As String
FileToBlob = "C:\temp\1.pdf"
Sql = "INSERT INTO dbo_Doc (Doc) VALUES (FileToBlob)"
DoCmd.RunSQL Sql
解决方案
使用此函数检索指定文件的字节数据:
' fPath is the path to the file
Function FileToBlob(fPath As String) As Variant
Dim fileNum As Long
Dim b() As Byte
fileNum = FreeFile
Open fPath For Binary As fileNum
ReDim b(LOF(fileNum))
Get fileNum, , b()
Close fileNum
FileToBlob = b
End Function
推荐阅读
- java - Java 中循环技巧的 Helloworld 示例
- c++ - 从 txt 文件中删除注释
- ios - 如何在 UITableView 中执行网络调用
- spring - 如何使用 Spring Boot 资源服务器拥有未经身份验证的端点
- python - 如何在 Python 中读取和写入 config.ini 文件?
- java - 使用 java 和 jsoup从网站上的标签中提取 src 值
- vb.net - 错误:无法为输出文件 #0 写入标头(编解码器参数不正确?):参数无效
- python - get() 接受 2 到 3 个位置参数,但给出了 4 个。为什么会出现这个错误?解决方案是什么?
- python - 如何提取
- java - 当定义的对象已经存在于地图中时,从我的地图中获取空返回值?