Hi

Hi
i am having issue to save PDF file to MS SQL Table, with following code and i am getting error (Error image has attach) please kindly some one help me to solve the issue, thanks


procedure TEmployProfile.AdvGlassButton6Click(Sender: TObject);
var
FileName: string;
FileStream: TFileStream;
BlobField: TBlobField;
const
SBlobFieldName: string = '';
begin
FileName := '';
if OpenDialog1.Execute then
FileName := OpenDialog1.FileName;
if FileName = '' then
Exit;
FileStream := TFileStream.Create(FileName, fmOpenRead);
QDocument.Open;
try
QDocument.Insert;
BlobField := QDocument.FieldByName('EMPDOCUMENT') as TBlobField;
BlobField.LoadFromStream(FileStream);
QDocument.Post;
finally
FileStream.Free;
end;
end;





Comments

  1. TDBImage works with images only. If you need preview the PDF, you need use the TOLEContainer but Adobe Reader must be installed on computer.

    Just save the content from BLOB field to temporary file and load in TOLEContainer

    ReplyDelete
  2. It's messy to extract a thumbnail using OLE. And all machines must have same / Similar PDF sortware. There are libraries (also with sourcecode, Debenu, Gnostice) to extract thumbnails from PDFs. I guess there's even free alternatives.

    ReplyDelete

Post a Comment