我是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