This is my code; I have a table that contains blob variables and I need to retrieve it and add to a image. this is my code and it not working
procedure TForm1.Button1Click(Sender: TObject);
var mybitmap, newBitmap: TBitmap;
str, query: string;
sqlQRY: TSQLQuery;
BLOB: TBlobField;
Ts : TMemoryStream;
bl : TBlobData;
begin
SQLConnection1.Open;
mybitmap:= TBitmap.Create;
mybitmap.Width :=25;
mybitmap.Height := 25;
query := 'SELECT * FROM CATEGORY_TYPES';
sqlQRY := TSQLQuery.Create(self);
sqlQRY.SQLConnection := SQLConnection1;
sqlQRY.SQL.Add(query );
sqlQRY.Open;
while not sqlQRY.Eof do
begin
if not sqlQRY.FieldByName('ICON').IsNull then
begin
BLOB := sqlQRY.FieldByName('Icon') as TBlobField;
ts := TMemoryStream.Create;
BLOB.SaveToStream(ts);
ts.Position :=0;
mybitmap.LoadFromStream(Ts);
Image1.Picture.Assign(mybitmap);
end;
sqlQRY.Next;
end;
sqlQRY.Close;
end;
The above code is not working; it shows an error message that bitmap is not can any one fix it?