Solved

Saving and retrieving JPG/GIF from FireBird

Posted on 2004-03-22
1
571 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this Micro Tutorial viewers will learn the basic shortcuts and functions in InDesign.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

766 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