Page 1 of 1

Bit field locate/filter on true/1 fails in TClientDataSet

Posted: Fri 23 Jan 2009 17:47
by Freerk
Hello,

We are using the TClientDataSet -> Provider -> TMSSQLQuery setup in Delphi 6.
Column of type "Bit" shows True/False ok in dataset, but locate and lookup and filter methods fail (no results) when searching/filtering for "True" or "1" values, even though there are many rows with "True" in this column. Searching/filtering for "False" or "0" works ok.


Regards,
Freerk Jelsma
SchoolMaster BV

Posted: Fri 23 Jan 2009 19:17
by Freerk
I've found out it writes the data as -1 for true and 0 for false, so I've made a quick fix myself in OLEDBAcess.pas in the inline function PrepareConvertableFields of Fetch.

dtBoolean:
if Boolean(WordBool(Marshal.ReadInt16(pValue))) then
Marshal.WriteInt16(pValue, 1)

So now I write 1 instead of -1.
TClientDataSet works fine with this quick fix.

Any comments?


Regards,
Freerk Jelsma
SchoolMaster BV

Posted: Tue 03 Feb 2009 10:31
by Dimon
We can't apply this fix because standard Delphi dataset keeps "True" boolean value as the WordBool value equal to $FF. Even ADO has similar behaviour.