Board index » delphi » Creating dBase-tables - unvalid outside of Delphi

Creating dBase-tables - unvalid outside of Delphi

Hello friends!

I create dbase-tables at runtime and it works inside the Delphi
environment - in my applications and in the Delphi Desktop. But when I
try to open the tables in Visual dBase or in Excel I get the complaint
that the tables are not valid dBase-tables or the format is unknown.
Dbase-tables created trough the desktop works alright in Visual dBase
and Excel.

I use this code in small variations to create the tables:

with Table1 do begin
    Active := False;
    DatabaseName := '';
    TableName := 'Cust5';
    TableType := ttdBASE;
    with FieldDefs do begin
      Clear;
      Add('LastName', ftString, 30, False);
      Add('FirstName', ftString, 20, False);
    end;
    CreateTable;
    AddIndex('FullName', 'LastName + FirstName', [ixExpression]);
end;

When I use the similar online example to create Paradox-tables there are
now such problem. Something like this:

with Table1 do begin
    { The Table component must not be active }
    Active := False;
    { First, describe the type of table and give }
    { it a name }
    DatabaseName := '';
    TableType := ttParadox;
    TableName := 'A4';
    { Next, describe the fields in the table }
    with FieldDefs do begin
        Clear;
        Add('ArtNr',ftString, 8, False);
        Add('Product', ftString, 20, False);
        Add('Number', ftInteger, 0, False);
      end;
    { Call the CreateTable method to create the table }
    CreateTable;
  end;

I hope you can help me with this {*word*193} one. Have I missed something? The
strange thing is that everything looks alright in the Delphi
environment.

I use win 2000.

Best wishes
Klas Westholm

--
Klas Westholm
Studera.nu/Informationsavdelningen
H?gskoleverket
Box 7851
103 99 Stockholm
Tel: 08-563 086 26
Fax: 08-563 086 00
E-post: Klas.Westh...@hsv.se
Hemsidor:
Studera.nu, http://www.hsv.se/studera
H?gskoleverket, http://www.hsv.se

 

Re:Creating dBase-tables - unvalid outside of Delphi


You need to set the TableLevel property of the TTable object before creating
the table (or in the BDE Administrator, change the default level for DBASE
tables (on the Configuration tab, set
Configuration-Drivers-Native-DBASE-Level.) This will only affect tables
which you create. You will still be able to open
tables of any DBASE level.
This specifies the format for DBASE - I have found that valid levels are 3,
4, 5 and 7
MS Office and many other applications only recognise DBASE 3 (and 4
possibly?).

It took me ages to work this out!

Hope this helps.

Chris

Quote
"Klas Westholm" <Klas.Westh...@hsv.se> wrote in message

news:3B83B0A5.F8C546EF@hsv.se...
Hello friends!

I create dbase-tables at runtime and it works inside the Delphi
environment - in my applications and in the Delphi Desktop. But when I
try to open the tables in Visual dBase or in Excel I get the complaint
that the tables are not valid dBase-tables or the format is unknown.
Dbase-tables created trough the desktop works alright in Visual dBase
and Excel.

I use this code in small variations to create the tables:

with Table1 do begin
    Active := False;
    DatabaseName := '';
    TableName := 'Cust5';
    TableType := ttdBASE;
    with FieldDefs do begin
      Clear;
      Add('LastName', ftString, 30, False);
      Add('FirstName', ftString, 20, False);
    end;
    CreateTable;
    AddIndex('FullName', 'LastName + FirstName', [ixExpression]);
end;

When I use the similar online example to create Paradox-tables there are
now such problem. Something like this:

with Table1 do begin
    { The Table component must not be active }
    Active := False;
    { First, describe the type of table and give }
    { it a name }
    DatabaseName := '';
    TableType := ttParadox;
    TableName := 'A4';
    { Next, describe the fields in the table }
    with FieldDefs do begin
        Clear;
        Add('ArtNr',ftString, 8, False);
        Add('Product', ftString, 20, False);
        Add('Number', ftInteger, 0, False);
      end;
    { Call the CreateTable method to create the table }
    CreateTable;
  end;

I hope you can help me with this {*word*193} one. Have I missed something? The
strange thing is that everything looks alright in the Delphi
environment.

I use win 2000.

Best wishes
Klas Westholm

--
Klas Westholm
Studera.nu/Informationsavdelningen
H?gskoleverket
Box 7851
103 99 Stockholm
Tel: 08-563 086 26
Fax: 08-563 086 00
E-post: Klas.Westh...@hsv.se
Hemsidor:
Studera.nu, http://www.hsv.se/studera
H?gskoleverket, http://www.hsv.se

Re:Creating dBase-tables - unvalid outside of Delphi


Quote
>I create dbase-tables at runtime and it works inside the Delphi
>environment - in my applications and in the Delphi Desktop. But when I
>try to open the tables in Visual dBase or in Excel I get the complaint
>that the tables are not valid dBase-tables or the format is unknown.
>Dbase-tables created trough the desktop works alright in Visual dBase
>and Excel.

>I use this code in small variations to create the tables:

Check your BDE config for the default Table level for dbase tables.  You will
probably find that this is set to 7.  Level 7 tables are not compatible with a
lot of programs.   BDE 5 introduced Level 7 tables and they are not compatible
with older BDE versions or other dbase drivers.
You can set the default Table level to something lower than 7 and give that a
try.  If you have Delphi 5 or above you can use the TableLevel property in your
code.
The Code you have for creating a table looks ok but beware that there are some
field types that when used will always give you a level 7 table.
For instance if you use ftFloat to specify field type you get a level 7 table.
You need to use ftBCD to create dbase number fields.

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

Re:Creating dBase-tables - unvalid outside of Delphi


Thank you Chris!

I suspected something like this but I didnt know how to solve it. You saved me
a lot of time and effort!

Yours
Klas

Quote
Chris Morgan wrote:
> You need to set the TableLevel property of the TTable object before creating
> the table (or in the BDE Administrator, change the default level for DBASE
> tables (on the Configuration tab, set
> Configuration-Drivers-Native-DBASE-Level.) This will only affect tables
> which you create. You will still be able to open
> tables of any DBASE level.
> This specifies the format for DBASE - I have found that valid levels are 3,
> 4, 5 and 7
> MS Office and many other applications only recognise DBASE 3 (and 4
> possibly?).

> It took me ages to work this out!

> Hope this helps.

> Chris

> "Klas Westholm" <Klas.Westh...@hsv.se> wrote in message
> news:3B83B0A5.F8C546EF@hsv.se...
> Hello friends!

> I create dbase-tables at runtime and it works inside the Delphi
> environment - in my applications and in the Delphi Desktop. But when I
> try to open the tables in Visual dBase or in Excel I get the complaint
> that the tables are not valid dBase-tables or the format is unknown.
> Dbase-tables created trough the desktop works alright in Visual dBase
> and Excel.

> I use this code in small variations to create the tables:

> with Table1 do begin
>     Active := False;
>     DatabaseName := '';
>     TableName := 'Cust5';
>     TableType := ttdBASE;
>     with FieldDefs do begin
>       Clear;
>       Add('LastName', ftString, 30, False);
>       Add('FirstName', ftString, 20, False);
>     end;
>     CreateTable;
>     AddIndex('FullName', 'LastName + FirstName', [ixExpression]);
> end;

> When I use the similar online example to create Paradox-tables there are
> now such problem. Something like this:

> with Table1 do begin
>     { The Table component must not be active }
>     Active := False;
>     { First, describe the type of table and give }
>     { it a name }
>     DatabaseName := '';
>     TableType := ttParadox;
>     TableName := 'A4';
>     { Next, describe the fields in the table }
>     with FieldDefs do begin
>         Clear;
>         Add('ArtNr',ftString, 8, False);
>         Add('Product', ftString, 20, False);
>         Add('Number', ftInteger, 0, False);
>       end;
>     { Call the CreateTable method to create the table }
>     CreateTable;
>   end;

> I hope you can help me with this {*word*193} one. Have I missed something? The
> strange thing is that everything looks alright in the Delphi
> environment.

> I use win 2000.

> Best wishes
> Klas Westholm

> --
> Klas Westholm
> Studera.nu/Informationsavdelningen
> H?gskoleverket
> Box 7851
> 103 99 Stockholm
> Tel: 08-563 086 26
> Fax: 08-563 086 00
> E-post: Klas.Westh...@hsv.se
> Hemsidor:
> Studera.nu, http://www.hsv.se/studera
> H?gskoleverket, http://www.hsv.se

Re:Creating dBase-tables - unvalid outside of Delphi


Quote
>So - just to confirm - am I right in thinking that setting the BDE to
>level 3 dBase and choosing a ftinteger in the table forces a ftFloat to
>be used instead  causing a level 7 table? (Which is what seems to happen
>on my system) and the fix is to use a ftBCD ?

Could be.  I can't remember if an FtInteger causes this problem.  But you can
check it by just dropping ftInteger from your table create and seeing what level
you get.   Aslo setting a field to Required when you create it always gives you
a level 7 table.

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

Re:Creating dBase-tables - unvalid outside of Delphi


I think it's the other way round - dBASE III and IV only have a NUMBER type,
so all integer fields are actually float fields with 0 decimal places. Look
in the help for Database Desktop (look under "field types" in the index -
this gives useful lists of field types for most of the databases supported
by BDE).

Quote
<m...@thisplace.com> wrote in message

news:MPG.15f377a1ced4de619896b7@newsgroups.borland.com...
Quote

> Thanks brian - I hadn't realised this level change happened and I rely
> on components that only work on level III

> I'll check it out as you suggest.

> john

Other Threads