Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Saving and retrieving JPG/GIF from FireBird

Posted on 2004-03-22
1
Medium Priority
?
578 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Learn how to create interesting presentations by including videos to keep your audience engaged using Prezi. Select "Insert" from the top menu in your Prezi editor: Select "YouTube Video": Paste the video URL into the prompt: "Select "Insert":…
Not only does Prezi allow you to create non-linear presentations, it also makes it easy to apply transition animations between your frames. Learn how to apply a fade-in transition to select items and entire frames in this tutorial Select "Edit Path"…
Suggested Courses

718 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