Solved

How To Save PDF to Blob field in MS Access

Posted on 2007-03-19
5
909 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 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

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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