Solved

How To Save PDF to Blob field in MS Access

Posted on 2007-03-19
5
822 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
yuppers, it was grabbing the wrong record, works perfectly!  Thanks! Quick and simple.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now