The information in this article applies to:
- Microsoft Visual FoxPro for Windows, version 3.0
SUMMARY
If a Database Container (.DBC file) becomes corrupted or damaged, it may
generate error number 1552: File "<filename>" is not a database. This
article shows by example how to trap for this error by using an ON ERROR
routine.
MORE INFORMATION
To demonstrate, perform the following steps:
- Create a new database and call it DATA1.DBC
- In the Database Designer, right click and choose New Table. Create a new
table with the following fields:
Field Type Width
-----------------------
Test1 character 10
Test2 character 10
When prompted to Input Data Records Now, choose Yes and add data to the
table.
- Issue the following commands in the Command Window:
CLOSE ALL
USE c:\vfp\data1.dbc &&actual path to your .DBC file may be different
BROWSE
CAUTION: If you are using an existing file instead of the example file
created here, please back it up before proceeding to the next step.
- Change the PARENTID in the first record to 0, then Save and Close the
table.
- Type the following into a program and run it:
ON ERROR DO errhand && To trap, and send to the error
&& handler procedure
OPEN DATABASE SYS(2004)+'data1.dbc' && An existing corrupt DBC file
ON ERROR && To reset ON ERROR to default
PROCEDURE errhand && The error handler
IF ERROR()=1552 && Check which error occurred
WAIT WINDOW 'Error #: '+STR(ERROR())+' Message: '+MESSAGE()
ENDIF
The error message "Error #1552 Message:File C:\VFP\DATA1.DBC is not a
database." should be displayed in a Wait window.
|