BLOB in TLiteQuery

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
scarrab
Posts: 3
Joined: Sat 23 Jul 2011 16:30

BLOB in TLiteQuery

Post by scarrab » Fri 10 May 2013 14:43

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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: BLOB in TLiteQuery

Post by AlexP » Mon 13 May 2013 08:33

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

scarrab
Posts: 3
Joined: Sat 23 Jul 2011 16:30

Re: BLOB in TLiteQuery

Post by scarrab » Mon 13 May 2013 20:26

Thanks Alex,
that's what I need, with your advice helped me a lot ... thanks ...

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: BLOB in TLiteQuery

Post by AlexP » Tue 14 May 2013 06:42

Hello,

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

Post Reply