?
Solved

How To Save PDF to Blob field in MS Access

Posted on 2007-03-19
5
Medium Priority
?
945 Views
Last Modified: 2010-04-05
I've spent a while looking on EE for an answer but everything is about storing images in access (can't load a pdf info an image box...). I need to store a PDF file (or any file for that matter) into a OLE Object field in an Access DB. The files this time happen to be PDF.

Code examples would be appreciated!
0
Comment
Question by:digitalwav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 18748507
not tested :


procedure TForm1.Button1Click(Sender: TObject);
var prm: TParameter;
begin
 prm := ADOQuery1.Parameters.AddParameter;
 prm.Name := 'pic_data';
 prm.LoadFromFile('file_name.pdf', ftBlob);
 ADOQuery1.SQL.Add('insert table_name(blobfield) values (:pic_data)');
end;


ziolko.
0
 
LVL 18

Accepted Solution

by:
Johnjces earned 2000 total points
ID: 18749004
Using ADO, an ADOQuery (and ADOTable would work just as well) and an Access database table you might try:

To Load it to the db

(ADOQuery1.FieldByName('MyPDF') as TBlobField).LoadFromFile('PDF_FileName.pdf');

To restore the file:

(ADOQuery1.FieldByName(MyPDF') as TBlobField).SaveToFile('PDF_FileName.pdf');

The field type is a picture or image field, by the way.
0
 
LVL 1

Author Comment

by:digitalwav
ID: 18750104
well, the load it to the db seems to work, but getting it back out results in a zero size file.
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 18751314
Hmmm... Don't know. Werks fer me!

The only problem I could envision would be your field type is something other than a OLE Object for an Access database table or in the case of MS SQL something other than an image field type, or the field is empty. Your cursor might on the wrong record.

Hope you get it!

John

0
 
LVL 1

Author Comment

by:digitalwav
ID: 18752629
yuppers, it was grabbing the wrong record, works perfectly!  Thanks! Quick and simple.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question