Page 1 of 1

Zeos + Lazarus + Firebird - Numbers < 10 with 2 decimals

Posted: 16.09.2010, 02:50
by Mando
Hi.
I'm newer with zeos in lazarus and firebird.
I've a table with a numeric (decial, float, double ...) field. I post into it a value less than 10 with a 2 (or more) decimals (p.e. 5.92) and the value is posted right in the table, but the control (aka TDBEdit, TDBGrid) doesn't reflect the correct value, it shows the value without last decimal. (p.e 5.92 -> 5.9). That doesn't occurr with values greater than or equal to 10.
I know I can play with precission in the field definition, but I'm developing a Database administration utility, and I open the tables dinamically.

Is that a bug? zeos 7 alpha has the same behavior than 6.6 stable.
What can i do to solve it ?

SQLdb works properly.


Thanks, regards from Spain.

(excuse my english)

Posted: 17.09.2010, 19:17
by guidoaerts
change the displayformat property of the numeric field
for example : TFloatField.DisplayFormat := '0000.00'

Guido

Posted: 20.09.2010, 12:10
by Mando
Thanks for your response, guidoaerts. But I'm creating several Tztable and query components dinamically, and I don't want to do the fields definition
manually. Is there another way to solve this?


Thanks in advance.

Posted: 20.09.2010, 14:39
by guidoaerts
I think you can change these properties dynamically after creating the components.

var
i: integer;

with TZTable.create do
begin
Connection := 'YourZConnection';
TableName := 'YourTable';
open;

for i := 0 to FieldCount-1 do
begin
if Fields.FieldKind = fkData then if Fields.DataType =ftFloat then
TFloatField(Fields).DisplayFormat := '0000.000';
end;
end;

Guido

Posted: 21.09.2010, 01:06
by Mando
Thanks, Guido, for your response. That is not exactly I'm looking for, but is a good porvisional solution.
However, this would be the right DisplayFormat: '0.00'. Only one zero in the left side and the required zeros in the right side. Also we can use the format char '#' to specify optionals spaces for decimals.
Example:
(0.00 ) 5.923 -> 5.92 , 8.6 -> 8.60
(0.0##) 5.923 -> 5.923, 8.6 -> 8.6

Thanks again.