Solved

How To Save PDF to Blob field in MS Access

Posted on 2007-03-19
5
857 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
  • 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 500 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 156
JAudiorecorder record freezing the app 29 67
Delphi: barcode reading on android platform 1 28
Twebbrowser add css to the header 3 24
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

775 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