Discussion:
Table corrupted
(too old to reply)
Sithu
2009-09-22 10:08:38 UTC
Permalink
Hi all,

Let's say I have a table named "my_table.dbf".
While my application runs, the table is in use.
At this moment, system shuts down because of power failure.
When I restart my application, I got an error message "my_table.dbf
has been corrupted".

How can I avoid this error ?
Any idea?

With regards,
Sithu
tom knauf
2009-09-22 11:09:25 UTC
Permalink
Hi,

to be sure , use an usv (add. power supply, for example from APC) which with
a battery covers your power failure or (if too long) gracefully shuts down
the computer .
As far as I know on a quit of a foxpro app all used tables are closed
automatically.

Repairing a dbf ,exspecially with memofields, can be a real pain.

HTH
Tom
Post by Sithu
Hi all,
Let's say I have a table named "my_table.dbf".
While my application runs, the table is in use.
At this moment, system shuts down because of power failure.
When I restart my application, I got an error message "my_table.dbf
has been corrupted".
How can I avoid this error ?
Any idea?
With regards,
Sithu
Sithu
2009-09-22 11:39:20 UTC
Permalink
Thank your for your advice.

The problem is not for my side; it is for user side.
I cannot handle the user side : user's hardware.
What I want to know is to handle the problem by the application
( program ).

I have a feature "Backup and Restore" in my system.
When the above problem occurred, re-install the application and
restore the old data which are backup last time.

Is there any better solution than "Backup and Restore" ?

With Regards
Sithu.
tom knauf
2009-09-22 11:49:46 UTC
Permalink
Hello,

no, to my opinion there is no better solution in case its a commercial
project.
Because if you try to solve it (just reindexing, use a repair tool,..) its
YOUR responsibility that everything is ok again.
In case that the user uses his backups & restore , its his responsibility to
have a proper and working backup stored on an EXTERNAL device.

Regards
Tom



Because for backup
Post by Sithu
Thank your for your advice.
The problem is not for my side; it is for user side.
I cannot handle the user side : user's hardware.
What I want to know is to handle the problem by the application
( program ).
I have a feature "Backup and Restore" in my system.
When the above problem occurred, re-install the application and
restore the old data which are backup last time.
Is there any better solution than "Backup and Restore" ?
With Regards
Sithu.
Sithu
2009-09-23 02:45:27 UTC
Permalink
Thank you, Tom
Jürgen Wondzinski
2009-09-23 13:10:52 UTC
Permalink
Hi Sithu,
Post by Sithu
How can I avoid this error ?
Best for avoiding is: Do not interupt your application ;) Of course we all
know that you can't be responsible for hardware or power failures, thus the
question should be: How to gracefully correct that problem.

In VFP8 and VFP9, there's the new SET TABLEVALIDATE setting, which defaults
to a basic tablecheck at the opening of a table. It compares the stored
recordcounter-value with the physical size of the table on disk. If that
doesn't match, it raises this error. This mismatch is normally 99% of all
table-problems and you can easily fix this:

*------------------------------------
FUNCTION RepairTable( cTableName )
*------------------------------------
LOCAL nOldSet
nOldSet = SET("TableValidate")
SET TABLEVALIDATE TO 0
TRY
USE cTableName EXCLUSIVE
APPEND BLANK
USE
USE cTableName EXCLUSIVE
GO BOTTOM
DELETE
PACK
USE
CATCH
MESSAGEBOX("Cannot repair table "+ cTableName,64)
ENDTRY
SET TABLEVALIDATE TO nOldSet
ENDFUNC
*------------------------------------

Notice the PACK, which ensures that all memos and indices are also
rewritten. This is a MUST-HAVE after any table corruption, since you can't
be sure what part of information was already written to disk when the
failure happened
--
wOOdy
Visual FoxPro Evangelist
Microsoft "Most Valuable Professional" 1996 to 2009



"*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
..·`.Visual FoxPro: It's magic !
(¸.·``··*
Sithu
2009-09-28 05:13:04 UTC
Permalink
Thank you Wondzinski.

I didn't test your solution. I'm sure that it will be useful.
But, your solution can cause auto-increment value changes after APPEND
BLANK and PACK.

Is there VFP command to handle auto-increment start value of a table ?

With Regards,
Sithu.

Loading...