How to Prevent Data Loss and Corruption in Databases

If you are using a local database (i.e. dBase or Paradox) then you probably ale have the BDE setting “LOCAL SHARE” set to false, which does not save changes to databases after they are modified immediately. The changes are kept in memory and saved later. In other words - cached.

This usually helps speed up database modifications because you don’t have a physical write after each and every change.
The problem may occur when your application (or Microsoft Windows itself :-) ) crash. That’s when you know that your changes are gone forever. To work around this just save the database after every posting. Just add code to your TTable’s AfterPost property.

uses
  BDE;
  ...
procedure TForm1.Table1AfterPost(DataSet: TDataSet);
begin
  DbiSaveChanges(Table1.Handle);
end;

Tags: , , , , , , , , , , , , , , , ,

No Comments Yet

You can be the first to comment!

Leave a comment

OpenID Login

Standard Login