将文件插入访问表 [英] Insert file into access table

查看:63
本文介绍了将文件插入访问表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为Reports的表,该表具有3个字段ID(自动编号),filename(字符串字段),theFile(附件字段).

I have a table named Reports which has 3 fields ID (auto number), filename (string field), theFile (attachment field).

我要运行的是SQL查询,然后将PDF文件插入附件字段(theFile).

What I want to is to run a SQL query and insert a PDF file into the attachments field (theFile).

可以说PDF文件位于C:驱动器(C:\ report1.pdf)中,我已经尝试了下面的SQL查询,但是它不起作用.我知道将文件存储在数据库中不是一个好习惯,但我只想尝试一下:

Lets say the PDF file is located in the C: drive (C:\report1.pdf), I have tried the SQL query below but it is not working. I know its not good practice to store files in a database but I just want to try it out:

CurrentDb.Execute "INSERT INTO Reports (filename,theFile) VALUES ('report1'," & C:\report1.pdf & ")"

推荐答案

将文件存储在数据库中是标准做法. Access当然支持它,但是不通过SQL.您必须使用DAO,如

It's standard practice to store files in a database. Access certainly supports it, but not through SQL. You'll have to use DAO, as detailed at http://msdn.microsoft.com/en-us/library/office/bb258184%28v=office.12%29.aspx

这篇关于将文件插入访问表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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