Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why are my Dbase files unrecognizable outside Delphi?

Status
Not open for further replies.

cold25

Programmer
Feb 11, 2002
41
US
My database program creates .dbf files, which I understand as being DBase files. I can display, edit and save my progress on these new .dbf files on my form's DBGrid. So, this table works fine with my delphi program. What I'm wondering is why is it that Excel gives me the message "This file is not in a recognizable format." when I try to open the .dbf file that I created with my delphi program?
Excel opens the other .dbf files that came with delphi (such as "clients.dbf") just fine, so what is wrong with the .dbf files that my delphi program is creating? I should be able to open them in Excel or any other program that opens .dbf files, right?

***I have tried seperately using both of these lines below, but it didn't seem to make a difference:
TableType := ttDbase;
TableType := ttDefault;

***Here is how I create a table in the program (pretty much straight out of Delphi Help):

with Table1 do begin
Active := False;
// DatabaseName := '; //Purposely left blank for now.
TableType := ttDbase;
TableName := 'CustInfo';

{ Don't overwrite an existing table }
if not Table1.Exists then begin
with FieldDefs do begin
Clear;
with AddFieldDef do begin
Name := 'Number';
DataType := ftString;
Size := 10;
end;
with AddFieldDef do begin
Name := 'Name'
DataType := ftString;
Size := 10;
end;
with AddFieldDef do begin
Name := 'Address';
DataType := ftString;
Size := 10;
end;
with AddFieldDef do begin
Name := 'Age';
DataType := ftInteger;
end;
with AddFieldDef do begin
Name := 'Status';
DataType := ftInteger;
end;
end; //end of with FieldDefs do begin

{ Next, describe any indexes }
with IndexDefs do begin
Clear;
{ The 1st index has no name because it is a primary key}
with AddIndexDef do begin
Name := '';
Fields := 'Number';
Options := [ixPrimary];
end;
end;
{ Call the CreateTable method to create the table }
CreateTable;
end;
end;


Any help would be greatly appreciated.

cold25
 
I don't think that ftInteger is a valid field type for dBASE files. You probably need to use ftBCD and you would need to specify the size of the field.

I suggest that you create a similar specification dBASE file using Database Desktop and then with a binary editor compare that with the file you created using Delphi. You should be able to identify the differences.

It may be that Excel only supports a limited number of dBASE file formats (eg only dBASE III and not dBASE IV).

Andrew
 
Thanks for your reply. I made a dBASE file using Database Desktop as advised and it opens fine in Excel. I also replaced all the ftInteger parts with ftBCD and put Size := 10; underneath that, however that file won't open in Excel yet. I would like to investigate the differences between the two with a binary editor as mentioned, but I'm not sure how to do that. What is an example of a binary editor that I could open the two files with that would display the differences which I'm looking for?

cold25
 
There are lots of good third party editors around. I use EditPad Pro which can display files in hexadecimal and can compare two files highlighting the differences. It has other excellent features and was, I believe, developed using Delphi. See
Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top