Board index » delphi » Delphi 4.0 - trouble creating DBase tables using code

Delphi 4.0 - trouble creating DBase tables using code

Hi,

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.Clear;

        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) ) ');

        DBCreator.ExecSQL;

 

Re:Delphi 4.0 - trouble creating DBase tables using code


Quote
>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.

The dbase table type that gets created is Dbase 7 since the Database desktop
does not support level 7 tables that is why you see a problem there.

But I can't reproduce any problem setting the index name
I am using BDE 5.11 I suppose there could be a problem with an earlier venison
of BDE that I don't see.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Delphi 4.0 - trouble creating DBase tables using code


Do not set the IndexFiles property.  It is for use with non-structural
indexes whose base filename differs from that of the table.  (e.g. the
old .ndx style)

The IndexName property is the one to use.   If you clear the
IndexFiles property, you should be able to select the index with the
dropdown editor in the Object Inspector under IndexName.   I presume
it will be named 'COACODE'.

Personally I avoid dBase level 7 tables like bubonic plague.  They do
support additional features such as primary keys but are incompatible
with just about everything.

Regards,
Colin Acheson

On Sun, 2 Jul 2000 19:34:37 +1000, "Maggie Clark"

Quote
<sneer...@nor.com.au> wrote:
>Hi,

>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.Clear;

>        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) ) ');

>        DBCreator.ExecSQL;

Other Threads