EVariantTypeCastError Exception in DBGrids with message:
"Could not convert variant of type (Null) into type (Date)"
This occurs in TCustomDBGrid.InternalAutoSizeColumn, line 33:
procedure TCustomDBGrid.InternalAutoSizeColumn(aCol: Integer; aCanvas: TCanvas; aDatalinkActive: Boolean);
var
Field: TField;
C: TGridColumn;
ColWidth: Integer;
ARow,w: Integer;
s: string;
begin
Field := GetFieldFromGridColumn(ACol);
C := ColumnFromGridColumn(ACol);
if (C<>nil) and (C.Title<>nil) then begin
aCanvas.Font := C.Title.Font;
ColWidth := aCanvas.TextWidth(trim(C.Title.Caption));
aCanvas.Font := C.Font;
end else begin
if (Field<>nil) then begin
aCanvas.Font := TitleFont;
ColWidth := aCanvas.TextWidth(Field.FieldName);
end
else
ColWidth := 0;
aCanvas.Font := Font;
end;
if (Field<>nil) and aDatalinkActive then
for ARow := FixedRows to RowCount-1 do begin
FDatalink.ActiveRecord := ARow - FixedRows;
if Field.dataType<>ftBlob then
s := trim(Field.DisplayText)
else
s := '(blob)';
w := aCanvas.TextWidth(s);
if w>ColWidth then
ColWidth := w;
end;
if ColWidth=0 then
ColWidth := GetColumnWidth(ACol);
ColWidths[ACol] := ColWidth + 15;
end;
Lazarus 1.8.0, FPC 3.0.4
I use TODBCconnection to Informix. I have tried my application on several different DB's, only one reports this error. This may be because of error in DB.
I'm not feeling brave enough to do proper correction in DBGrids source code.
Please help me to filter out this exception.