Link to home
Start Free TrialLog in
Avatar of CultLeaderZero
CultLeaderZero

asked on

Access violation when attempting to open a dbf file

I am using Delphi 7, Apollo SDE 6.1. I have a Foxpro file (Syslog.dbf) as the source of a TApolloTable component. I am attempting to open the file with code and getting an access violation when I do so. I put in a view lines of code to check for the existence of the file and it returned true. I am not sure how to track down the source or cause of this error.
dm.Table_SysLog.Close;
  dm.Table_Archive.Close;
 
  if cLogToOpen = 'C' then begin
    dbGrid_Select.DataSource := dm.ds_Syslog;
    dm.Table_SysLog.Open;
  end;

Open in new window

Avatar of CultLeaderZero
CultLeaderZero

ASKER

Someone must have an answer or suggestion....
I don't think too many people are using Apollo!

Only one thing does comes to mind... are you certain the dbf is a good non-corrupted database file and truly a FoxPro file?

Do you open other database files in the same fashion and have them open just fine?

John
I am certain the dbf is good and it is a Foxpro file. I can open other dbfs with the same method. Thanks for your suggestion.
Will you please provide the exact error message?
Do you get an error on the close of the table?  (Also, you might want to test the table for being Active before arbitrarily closing it.)
if dm.Table_SysLog.Active then dm.Table_SysLog.Close;
if dm.Table_Archive.Active then dm.Table_Archive.Close;
 
  if cLogToOpen = 'C' then begin
    dbGrid_Select.DataSource := dm.ds_Syslog;
    dm.Table_SysLog.Open;
  end;

Open in new window

you are supposed to link dbgrid.datasource to table datasource and not the table itself.Or is "dm.ds_Syslog" the name of the datasource?
Pretty confusing your naming ....
 
@senad,
Pretty confusing your naming ....

Actually, the naming convention seems quite clear to me.  Tables appear to be named "Table_. . . " and DataSources appear to be named "ds_. . . ".
@CultLeaderZero,
Have you tried opening the file in question and one that your app can open in a Hex Editor and then comparing the the header informaation?  If it is the same (or "close enough"), then you may need to step through the the initial portion of the data to see if the table is properly defined.
Dot-DBF files have a 32 byte file/table header that provides information about the exact type of DBF file and the a lot of other file-related details including the number of columns.  Following the File Header, there is one 32 byte Column Header for each of the N columns.  Each  Column Header defined the Name, Type, Width, and some ofther factors about its column.  Finally, after the N+1 records, comes the data and it should match the definitions from the Coumn Headers.  The length of the record can be calculated from the sum of the column widths plus 1 (for the Deletion Flag).
Avatar of Geert G
have you tried opening the table with the delphi tool Database Desktop ?
ASKER CERTIFIED SOLUTION
Avatar of CultLeaderZero
CultLeaderZero

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial