Solved

Saving and retrieving JPG/GIF from FireBird

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Add visuals to your Prezi to keep your audience engaged. Learn how to embed images, edit them, and more in this video micro tutorial. Select "Insert" from the top menu in your Prezi editor: Select "Image": A toolbar will pop in from the right …
In addition to being a great web-based presentation tool, Prezi also makes it easy to save your presentation as a PDF to share with others as well. Learn how in this tutorial. Select the share icon from the top menu in your Prezi editor: Select "D…

762 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

23 Experts available now in Live!

Get 1:1 Help Now