'30/12/1899" shown instead of empty when a date is null
GoogleCodeExporter opened this issue · comments
Step to reproduce the problem?
- Use a db Grid from Developer Expres (Tcxgrid)
- Connect the grid to a table with a date column that in some rows is null;
I expect that where the value of Date Column is null the cell must be empty,
but instead is shown '30/12/1899".
I didn't try to use other data-aware visual components, but apparently,
modifying method "function TSQLiteUniTable.GetFieldsVal" in SQLiteTable3.pas
solves the problem i changed the assigments for empty values from "unassigned"
to "null":
function TSQLiteUniTable.GetFieldsVal(I: Cardinal): Variant;
var
//thisvalue: pstring;
thistype: integer;
dt1: TDateTime;
begin
Result := null; //unassigned;
if EOF then
raise ESqliteException.Create('Table is at End of File')
else if FieldIsNull(I) then
Exit;
//integer types are not stored in the resultset
//as strings, so they should be retrieved using the type-specific
//methods
thistype := FColTypes[I];
case thistype of
dtStr:
begin
Result := FieldAsString(I);
end;
dtInt:
Result := FieldAsInteger(I);
dtNumeric:
Result := FieldAsDouble(I);
dtBlob:
Result := FieldAsBlobVariant(I); // FieldAsBlobText(I);
dtDate:
begin
if not TryStrToDate(FieldAsString(I), dt1, fDB.FmtSett) then
Result := null //unassigned
else
Result := dt1;
end;
dtDateTime:
if not TryStrToDateTime(FieldAsString(I), dt1, fDB.FmtSett) then
Result := null //unassigned
else
Result := dt1;
else
Result := null; //unassigned;
end;
end;
Original issue reported on code.google.com by pgiacom...@gmail.com
on 12 Dec 2012 at 11:26
This issue was closed by revision r159.
Original comment by lnaginio...@gmail.com
on 12 Dec 2012 at 12:28
- Changed state: Fixed