SORRY FOR MY ENGLISH !! WHEN I HAVE ANY ELECTRICAL FAILURE IN MY COMPUTER ( FOR EXAMPLE, SHUT DOWN ) AND I HAVE SOME DATABASE OPEN, ALMOST EVER WHEN I RESTART MY SYSTEM, AND SELECT THE FILE, I HAVE THIS PROBLEM ... H E L P !!!!!
I'm sorry, but this is an unfortunate consequence of the .DBF file structure and the nature of operating system buffering. Since .DBF's carry both the data and a header record count, they can get out of sync when all buffered data can't be written out (this is the major reason that you get this error message).
Consider:
a) Getting a UPS to compensate for power failures.
b) Add procedures to not turn off the PC where the database resides, without first shutting down the application.
c) Close the file after each write/update in the application.
d) Get a utility to fix the database headers - there are many free ones available in addition to the commercial ones. Note: These won't reliably recover ALL the data lost, but they will get you back to the point where you can normally manually fix what may be missing.
Bottom line is to avoid the problem by addressing the hardware and procedural problems.
I used to get power failure header damage on a regular basis, and wrote my own recovery routines, using low level file commands. It's been a while, so I'm not prepared to write the step-by-step for you, but it can be done.
My method was a bit different than trying to correct the file length value in the header. You have to find your way past the header to the beginning of your first record and know the structure of the file. If you're interested in that approach I'll track down and send you some code that you could start with. And as Rick suggested, by all means, get a power supply. Good luck!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.