• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 868
  • Last Modified:

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

0
CultLeaderZero
Asked:
CultLeaderZero
1 Solution
 
CultLeaderZeroAuthor Commented:
Someone must have an answer or suggestion....
0
 
JohnjcesCommented:
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
0
 
CultLeaderZeroAuthor Commented:
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AndrewJenCommented:
Will you please provide the exact error message?
0
 
8080_DiverCommented:
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

0
 
senadCommented:
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 ....
 
0
 
8080_DiverCommented:
@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).
0
 
Geert GruwezOracle dbaCommented:
have you tried opening the table with the delphi tool Database Desktop ?
0
 
CultLeaderZeroAuthor Commented:
I found the problem. I had one of the fields of the table classified as a data field when it was actually a calculated field.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now