Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Problems loading image from blob
Fri, Sep 26 2008 3:43 PMPermanent Link

Darrell
Hi all ~

saving works like a charm - but loading from DB into a viewing component fails.
What am I doing wrong?

Thanks for your help
Darrell


//------------------------------------------------------------------------------
procedure TForm1.ButtonLoadFromDBClick(Sender: TObject);
var
 bs: TDBISAMBlobStream;

begin
 dbit.First;
 isb.Clear;   // clear image viewer
 try
   bs := TDBISAMBlobStream.Create( TBlobField( dbit.FieldByName( 'Image' )), bmRead );
   isb.Graphic.LoadFromStream( bs );
 finally
   bs.Free;
 end;
end;

//------------------------------------------------------------------------------
procedure TForm1.ButtonSaveToDBClick(Sender: TObject);
var
 bs: TDBISAMBlobStream;

begin
 if isb.Graphic.Empty then
 begin
   Showmessage( 'No image - no save!' );
   Exit;
 end;
 try
   dbit.Edit;
   try
     bs := TDBISAMBlobStream.Create( TBlobField( dbit.FieldByName( 'Image' )), bmWrite );  
     isb.Graphic.SaveToStream( bs );
   finally
     bs.Free;
   end;
   dbit.Post;
 except
   dbit.Cancel;
 end;
end;

//------------------------------------------------------------------------------
Fri, Sep 26 2008 6:14 PMPermanent Link

Darrell

Oops - never mind; the problem was with my image component.
Image