views:

95

answers:

1

The Firebird FAQ explains how to create a BOOLEAN domain. Probably the most interesting part is at the end, where it says:

If you use a connectivity library like OleDB under .Net, you can override the OleDB provider's GetSchema method, so the DataTables you get from queries have native .Net booleans.

Is there any way to do that with DB Express? I'm using the DBX driver from http://sites.google.com/site/dbxfirebird/, and it would sure be nice to be able to get back TBooleanField instances in my datasets instead of TSmallintField.

A: 

It is handled by these two methods that each TDataSet descendant can override:

function TDataSet.GetFieldClass(FieldType: TFieldType): TFieldClass;
begin
  Result := DefaultFieldClasses[FieldType];
end;

function TDataSet.GetFieldClass(FieldDef: TFieldDef): TFieldClass;
begin
  Result := GetFieldClass(FieldDef.DataType);
end;

--jeroen

Jeroen Pluimers
This is basically the same thing as Craig suggested. That will only work with data types that the DBX driver already recognizes. What I need is to teach it a new type, so it will generate TFieldDef objects whose data type is boolean in the first place.
Mason Wheeler
I think you can examine the TFieldDef to see what underlying meta information it contains (BOOLEAN is a domain holding only values 0 and 1, or can be NULL). I didn't have time to try this yet because I got family over; first chance will be after the holiday season.
Jeroen Pluimers