Spurious Data returned from empty db column...

From: Colin Basterfield (colin.basterfield_at_xtra.co.nz)
Date: 02/22/05


Date: Wed, 23 Feb 2005 11:38:59 +1300

Hi,

I'm using Delphi 7, with a MyDAC control to talk to a MySQL db. The table I
am pulling data from has a number of string fields, some of which can be
blank, so when the save to the database happens those fields are written
blank, i.e. '', in the DB and that is confirmed by querying the DB table
directly, however it seems that when those fields are subsequently retrieved
they are filled with spurious control characters.

In DB.pas there is a routine:

function TStringField.GetValue(var Value: string): Boolean;

and in here there is:

var
  Buffer: array[0..dsMaxStringSize] of Char;

declared locally, now it is this that is seemingly not initialised to
blanks, and therefore the value gets filled with whatever is in here, which
seems to be random.

Does this ring any bells with anyone, only it is confusing the users as data
they didn't enter in fields is appearing in them.

Many thanks in advance for any insights...

Cheers
Colin B