Page 1 of 1

DGBrid and float with Zeos?

Posted: 21.12.2005, 17:24
by martinalex
I simply want to display a float value on a DBGrid when the underlying database is Firebird with Zeos.
With BDE I can set the formatting for FLOAT and DECIMAL database columns using the columns editor and persistent fields. This does not exist for Zeos.

With Zeos I can format single values when assigning it e.g. to TEdit field with FloatToStr.
For a DBGrid I don't have this option. The float value is displayed as a weird integer.
I tried several DBGrids like TMDBGrid, TJvDBGrid and TDBGrid, all three can't show floats. :(
Is this a problem with the grids or is this a feature which a light middleware like Zeos does not support. Does someone know about a workaround?

I use D7 and Firebird 1.5 and Zeos 6.5.1

Posted: 22.12.2005, 09:24
by Domo Sokrat
Hi martinalex,

:shock: DBGrids & ZeosLib DBOs & persistent fields & formatted floats won't cause any problems!

I added a little sample (D2005 and ZeosLib DBO - latest CVS release) that uses the zeoslib test database (table "cargo" and its float field "c_cost"). It Runs perfectly when I create persistent fields for all the table fields and assigning a DisplayFormat string like "#.00" to the c_cost TFloatField and a DisplayFormat string like "#.0000" to the c_weight TFloatField. It also runs without problems if you define only certain columns to display within the DBGrid (see sample)!.

If you don't have the sample db. The cargo table will be created as follows:

[syntax="sql"]create table cargo (
c_id INTEGER not null,
c_dep_id SMALLINT,
c_name CHAR(10),
c_seal SMALLINT,
c_date_came TIMESTAMP,
c_date_out TIMESTAMP,
c_weight FLOAT,
c_width INTEGER,
c_height INTEGER,
c_cost NUMERIC(12,4),
c_attributes BLOB SUB_TYPE TEXT,
primary key (c_id)
);
[/syntax]

Regards.