#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    5
    Rep Power
    0

    Kylix: Floats from MySQL end up truncated in app


    Hello there,

    I'm new to Delphi/Kylix, so perhaps there's someone to help me out with kind of a strange problem.

    My application accesses a MySQL (3.23) server and tries to fetch some data from a table that includes a float column.

    Whenever I do something like
    SQLQuery1.FieldByName('floatcolumn').AsFloat
    I end up with an integer value (well, typed as float though).

    There's nothing wrong with the query, this doesn't even work when I use a TDBGrid to display rows from that table. A manual query via telnet e.g. reveals:

    mysql> select floatcol from sometable;
    +---------+
    | floatcol |
    +---------+
    | 83.7 |
    | 83.2 |
    | 84.1 |
    | 82.8 |
    | 83.5 |
    | 83.3 |
    | 84.4 |
    | 83.5 |
    +---------+
    8 rows in set (0.00 sec)

    The DBGrid only shows these numbers as
    83
    83
    84
    82

    and so on.

    Any ideas what could be wrong here? I'm using Kylix 3.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    I would check the underlying TField value and see what the value of TField.Precision is set to.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    5
    Rep Power
    0
    Originally Posted by Scorpions4ever
    I would check the underlying TField value and see what the value of TField.Precision is set to.
    Thanks for the hint. Help however says, that the "Precision" property must be greater than 2 and that it is automatically set to 2 if someone/something tries to set it to a value less than 2.

    In my case, the Precision is zero

IMN logo majestic logo threadwatch logo seochat tools logo