Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Saving and retrieving JPG/GIF from FireBird

Posted on 2004-03-22
1
Medium Priority
?
579 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 400 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
In this second Micro Tutorial in the series,  viewers will learn more basic shortcuts and functions of Illustrator. In this tutorial you will learn about the eyedropper tool, zoom , ellipses and more.
Learn how to download your full Prezi presentation for offline presenting. Prezi doesn’t have to be viewed and shared in a web browser, even with a free account you can download your full presentation to share with others. Be sure to download any vi…
Suggested Courses

876 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