How can i get Delphi 7 to return a '0' or '1' when the FieldType of a TQuery descendant's Field is a ftBoolean? By default this returns 'TRUE' or 'FALSE', that is
Query1.Fields[0].AsString
would return '0'
, not 'FALSE'
Use
(Query1.Fields[0] as TBooleanField).DisplayValues := 'TRUE;FALSE';
to set a string in the form of 'TRUE;FALSE' (or '1;0'). This allows you to define what values AsString will return.
If you added the field in design time, and/or you got yourself a boolean field component, you can use that too, without the typecast:
Query1YourBooleanField.DisplayValues := 'TRUE;FALSE';
By the way, it's not the query that returns '0', not is it the query that 'is' ftBoolean. These are the fields in the query that represent fields in the table or query result set.
Why not simple use Query1.Fields[0].AsInteger if you want a numerical representation for the boolean ? I think that should work ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With