gud day everyone !!! im using dbase for windows as my databse... since i have no UPS for my PC... i have no problem with my program but at times when there is power failure my indexfiles get corrupted... why ? whats the best thing to do?
Have you tried deleting the index (NDX?) file and then reindexing the table, perhaps using Database Desktop (Table, Restructure)? Once the index file is gone, you should be able to open the table.
If you mean how you could write an exception in the event the index is corrupted, you could do a DeleteFile for the index file, then run a query that will SQL CREATE or ALTER TABLE and add an INDEX.
You can also keep a blank DBF table (table B), along with it's index. When you index gets corrupted on table A, delete the table A index file. Add the records from table A to table B. Copy table B.DBF to A.DBF and copy B.NDX to A.NDX. Empty table B and get a standby generator. G'Luck.
Getting answers before I'm asked.
Providing answers if I can.
Unless your app is a single form with a DBGrid, there are usually areas of your program where the tables do not need to be open, like when the user is in a menu, for example. Most DB demo programs show opening the tables in OnCreate, the close the tables in OnDestroy, where in real life, this is a bad practice for the very reason you have described.
To protect your data, as a general rule, if a table doesn't need to be open in your code, close it.
I've gone as far as to put a timer on a DBGrid to close it if left open by a user. There nothing like a novice banging random keys to wake a suspended monitor with live data on the screen.
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.