I have a form (Delphi 2010) that includes several data controls, including a DBImage. All these are hooked to a underlying MSSQL 2005 database and table. I'm using ADOConnection and ADO Table for ease of use.

I need to include image data in this table, so I have set up a button that calls an OpenPictureDialog. This allows me to select the proper jpeg image which I want to then insert into the current table record.

This is my code:

procedure TForm2.Button1Click(Sender: TObject);
begin
  adotable1.Edit;
  if OpenPictureDialog1.Execute then
  begin
    DBImage1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
   end;
end;

This image then appears fine in my DBImage control, only it then disappears when I click Post on the DBNavigator.

How do I get the image to move (?) from the Picture to the underlying imagefield?

Hi,
Try This Code:

var
  EmpBmp: TBitmap;
begin
      EmpBmp := TBitmap.Create;
      try
        srcDB.DataSet.Edit;
        if OpenPictureDialog1.Execute(Handle) then begin
          DBImage1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
          EmpBmp.Assign(imgEmp.Picture.Graphic);
          DBModule.qryEmployeesEPPHOTO.Assign(EmpBmp);
      finally
        FreeAndNil(EmpBmp);
      end;

  end;
This question has already been answered. Start a new discussion instead.