Subject Re: [IBO] TFieldefs
Author Geoff Worboys
> Is the question to ot or does'nt anybody know.
> If it is to ot sorry about the post I will post it
> somwhere else.

Technically questions about TField, TDataset and TFieldDefs are VCL
related questions and are more likely to get an informed response from
Delphi/VCL forums. However...

> How do I know to what type of variant a fieldtype will
> be cast. If you cast it like the code underneath it only
> cast the fields that have values. The fields that dont
> have values stay null.

Because the true variant type can take any type of data (with certain
restrictions depending on what Delphi version, what platform and
whether using only VCL or also using MS DLLs). So when no value is
assigned to a variant there is no way of determining the type from the
variant variable.

Note that the variant capability is independant of the dataset field
types. It is simply used to make it more convenient to cast between
different fields of different types.

If want to save the type information from the FieldDefs then you
probably want the TFieldDef.FieldClass property. From the VCL online

"Use FieldClass to find out the class of field object this field
definition object corresponds to. The FieldClass is determined by the
DataType of the field. For example, if the DataType is ftString, the
FieldClass is TStringField."


Geoff Worboys
Telesis Computing