Page 1 of 1

BLOB in TLiteQuery

Posted: Fri 10 May 2013 14:43
by scarrab
I want to show data within a grid component. Most of the fields are strings or numbers and one field is an image - BLOB db field on SQLite.
I'm using the TLiteQuery component to select data from the SQLite-DB. Besides the SELECT statement I define the datatypes to show them in a grid using the DataTypeMapping property of TLiteQuery. Any used fields are working well besides BLOB fields. How do I have to map a BLOB field to show an image in a grid. Without mapping, the grid column only shows [BLOB].
I hope you can help me, thanks in advance.

Re: BLOB in TLiteQuery

Posted: Mon 13 May 2013 08:33
by AlexP
Hello,

The standard DBGrid doesn't support automatic displaying of images independently on used data access components. You should implement image displaying by yourself, for example, in the TDBGrid.OnDrawDataCell event:

Code: Select all

procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
  Field: TField; State: TGridDrawState);
var
  Bmp: TBitmap;
begin
  if Field.FieldName  = 'Graphic' then
  begin
    try
      Bmp:=TBitmap.Create;
      Bmp.Assign(Field);
      DBGrid1.Canvas.StretchDraw(Rect, Bmp);
    finally
      Bmp.Free;
    end
  end
  else
    DBGrid1.DefaultDrawDataCell(Rect, Field, State);
end;

Or use third-party grids, that allow automatically show data from Memo fields

Re: BLOB in TLiteQuery

Posted: Mon 13 May 2013 20:26
by scarrab
Thanks Alex,
that's what I need, with your advice helped me a lot ... thanks ...

Re: BLOB in TLiteQuery

Posted: Tue 14 May 2013 06:42
by AlexP
Hello,

Glad to see that the problem was solved. If you have any other questions, feel free to contact us.