View Single Post
 
Old 01-02-2017, 09:50 PM
kbboykin kbboykin is offline
Senior Member
 
Join Date: May 2005
Posts: 365
Default Solved

I solved this and found the way to add a standard image to the database when I don't have and image. I only show the code snippet that fixed what I wanted below

Code:
procedure TfrmWines.AutoSetDataChange(Sender: TObject; Field: TField);
var
  JPG:TJPEGImage;
  ms:TMemoryStream;
begin
  if autoset.DataSet.State = dsInsert then
  begin
    image1.Picture.Graphic.LoadFromFile('q:\sourcecode\mycellar\images\blk_wht_glass.jpg');
    Exit;
  end;
  begin
    JPG:=TJPEGImage.Create;
    ms:=TMemoryStream.Create;
    try
      TBlobField(wdatamod.mywines.FieldByName('winelabel')).SaveToStream(ms);
      ms.Position := 0;
      JPG.LoadFromStream(ms);
      Image1.Picture.Assign(JPG);
   finally
     JPG.Free;
     ms.Free;
   end;
  end;
end;
__________________
Using Delphi 2010 Professional as a Novice Programmer - self taught
Reply With Quote