Delphi 4.0 - Creating DBase Table using Code


I Have created  Dbase Files as you can see in the example code below which I
seem to be having some problems with.

1. The index that has been setup does not seem work as a sort order when I
use it in a form.  I have set IndexFiles for the form but cannot set either
IndexName or IndexFieldName as I get a 'Capability not supported' message.
2. If I try to do a SetKey using the field from the index I get a message
saying that Delphi couldn't find the index.
3. If I examine the Table  using Database Desktop The numeric fields do not
appear to be identifiable, the field definition and size show as blanks.
4. One field I create is 'numeric (3, 0)' and when I try to use it in a form
I get the error 'xxxTable: Type mismatch for  field 'yyy', expected smallnt
actual: Float' (this case is a little obscured as I created the form using
what should have been a table with an identical table format which was
created using the actual Dbase product).

Code example: -


        DBCreator.SQL.Add('create table "' + gVDatabaseDir +
gCTempTablePrefix + 'coa.dbf" (');
        DBCreator.SQL.Add('    COACODE  char  (6),    ');
        DBCreator.SQL.Add('    COAGROUP  char  (5),    ');
        DBCreator.SQL.Add('    COADESC  char (35),   ');
        DBCreator.SQL.Add('    COALASTYR numeric (12, 2),    ');
        DBCreator.SQL.Add('    COABALANCE numeric (12, 2),    ');
        DBCreator.SQL.Add('    COATYPE  char (2),        ');
        DBCreator.SQL.Add('    COALASTEX                date,
        DBCreator.SQL.Add('    COAEXREF  numeric (8, 0),   ');
        DBCreator.SQL.Add('    COAEXAMT  numeric (12, 2),  ');
        DBCreator.SQL.Add('    COALASTIN               date,
        DBCreator.SQL.Add('    COAINREF  numeric (8, 0),   ');
        DBCreator.SQL.Add('    COAINAMT  numeric (12, 2),  ');
        DBCreator.SQL.Add('    primary key (COACODE) ) ');