Solved

Saving and retrieving JPG/GIF from FireBird

Posted on 2004-03-22
1
569 Views
Last Modified: 2013-11-19
Hi,experts!

I need to save and retrieve jpg and gif files from a FireBird database.
Could someone give me an example code?

Thanks in advance,

Hederglan
0
Comment
Question by:hederglan
1 Comment
 
LVL 12

Accepted Solution

by:
esoftbg earned 100 total points
ID: 10649454
the function below can save images like Bitmap, Jpg, .... via TIBTable or TIBDataSet components into FireBird / InterBase database:
About retrieving these images you can just use TDBImage component for visualization...

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Clipbrd, ExtDlgs, DB, DBCtrls, JPEG, IBTable,
  IBCustomDataSet;

type
  TForm1 = class(TForm)
    DBImage1: TDBImage;
    OpenPictureDialog: TOpenPictureDialog;
    IBTable1: TIBTable;
    DataSource1: TDataSource;
  private  { Private declarations }
    function  DBImage_Post: Boolean;
  public   { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function  TForm1.DBImage_Post: Boolean;
var
  B:      Boolean;
  CB:     TClipboard;
  Image:  TImage;
begin
  B := False;
  try
    if OpenPictureDialog.Execute then
    begin
      CB := TClipboard.Create;
      try
        Image := TImage.Create(Self);
        try
          Image.Picture.LoadFromFile(OpenPictureDialog.FileName);
          CB.Assign(Image.Picture);
          if not (DBImage1.DataSource.DataSet.State in [dsInsert,dsEdit]) then
            DBImage1.DataSource.DataSet.Edit;
          DBImage1.Picture.Assign(CB);
          try
            DBImage1.DataSource.DataSet.Post;
            B := True;
          except
            B := False;
          end;
        finally
          Image.Destroy;
        end;
      finally
        CB.Destroy;
      end;
    end;
  finally
    Result := B;
  end;
end;

end.

emil
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Connection between libmysql.dll and MySQL Versions 7 87
How to make dynamic image files 3 84
Corel Draw -- open source replacement ? 8 84
Slow Printing 8 71
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

895 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

13 Experts available now in Live!

Get 1:1 Help Now