Solved

How To Save PDF to Blob field in MS Access

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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