Recent

Author Topic: how exactly read blob field  (Read 11124 times)

deepblue

  • New Member
  • *
  • Posts: 26
how exactly read blob field
« on: August 24, 2009, 01:52:08 pm »
i have a table with blob field..this field is for picture.
i have try to SQLdb and TDBImage component but it doesn't work.
my step is:
1. add SQLConnector. I set Connected to true and no error
2. add SQLQuery1. I set SQL with 'select * from product order by code'. and active property to true. no error
3. i double click in SQLQuery. I do Add Fields in 'Edit Fields - SQLQuery1'..i add 'picture' field as TBlobField.

the problem is:
i choose that tblobfield
and i saw strange Blobtype property (under Alignment in Object Inspector)..
that property's combobox shows: three empty space,??,??,{,Dataset,ef4V?,ftFixedWideChar,ftFMTBcd,ftGuid,ftIDispacth,ftInterface,ftOraBlob,ftOraClob,ftTimeStamp,ftvariant,ftWideMemo,TdatasetNotifyEvent.

CMIIW, it should be 'TBlobType = ftBlob..ftWideMemo;' (i saw in db.pas line 791)

is there a bug in FPC or LCL?

i tried to set SQLQuery1picture.BlobType:=ftGraphic; in form create procedure but it's doesn't show picture in tdbimage..

NB:I have same condition with Zeos

please help me..
thanks..

My Lazarus Version:Lazarus 0.9.29 r21262:21406M FPC 2.3.1 i386-win32-win32/win64
« Last Edit: August 24, 2009, 07:24:59 pm by deepblue »

Loesje

  • Full Member
  • ***
  • Posts: 157
    • Lazarus Support website
Re: how exactly read blob field
« Reply #1 on: August 25, 2009, 06:19:09 pm »
The format of the data in the blob-field has to be recognized by TDBImage. Try to add a picture in TDBImage, then write it to the database and then open it again. That way you know for sure that the format is ok. (Just binary data with a .gif or something won't work. It needs a header with the image-type)

halityilmaz

  • Newbie
  • Posts: 3
Re: how exactly read blob field
« Reply #2 on: August 25, 2010, 10:39:28 am »
this is not aout your question, i know and i am sorry but i want to ask you what you used for ConnectorType Property of SqlConnector?

I have ( unknown connector type) error every time when i want to connect to the sql server.

thank you.

guidoaerts

  • New Member
  • *
  • Posts: 12
Re: how exactly read blob field
« Reply #3 on: August 27, 2010, 09:08:06 am »
this is an example:

var
fstream : tStream;
fgraph : tjpegimage;   
begin
 if not (tblobfield(fieldbyname('foto')).IsNull) then
     begin
        fstream := gquery.CreateBlobStream(gquery.FieldByName('foto'),bmread);
        fgraph := tjpegimage.create;
        try
          fgraph.LoadFromStream(fstream);
          fotoimage.Picture.Assign(fgraph);
        finally
          fstream.free;
          fgraph.free;
        end;
     end;               
end;

Lacak2

  • Guest
Re: how exactly read blob field
« Reply #4 on: August 31, 2010, 07:43:11 am »
this is not aout your question, i know and i am sorry but i want to ask you what you used for ConnectorType Property of SqlConnector?

I have ( unknown connector type) error every time when i want to connect to the sql server.

It depends on type of SQL Server you are connecting to. For example:
ODBC: 'ODBC'
Oracle: 'Oracle'
MySQL: 'MySQL 4.1', 'MySQL 5.0'
Interbase, Firebird: 'Firebird'
etc.

But you can use instead of SQLConnector some of individual SQLConnections (TODBCConnection,TOracleConnection,...) objects when you know to which SQL Server you want connect to.