Board index » delphi » Data loss on power failiure

Data loss on power failiure

Please help if you can!!

The database I've written loses all data edited that day (and often corrupts
indexes) if the power goes down.  Can anyone tell me how I might avoid this
i.e force the data to the hard drive?  Posting and closing then opening
tables doesn't help - can't understand what's going on here.  Cache? RAM?

(using paradox tables, Delphi 2, win 95, pentium II)

Thanks.

 

Re:Data loss on power failiure


Hi
Is local share set to true in dbe?

HTH

Tanja

Re:Data loss on power failiure


<<Gareth Magennis skrev i meldingen <37a78c0...@news2.cluster1.telinco.net>...
Please help if you can!!

The database I've written loses all data edited that day (and often corrupts
indexes) if the power goes down.  Can anyone tell me how I might avoid this
i.e force the data to the hard drive?  Posting and closing then opening
tables doesn't help - can't understand what's going on here.  Cache? RAM?

(using paradox tables, Delphi 2, win 95, pentium II)

Quote

Hi !

  This is a well known problem, and has to do with performance. If the database was to write and
read physical disk files all the time, it would be slow. So, they are cached in memory. Then you
have a power failure (or a windows crash), and - voil - all is lost..

I have used this call in an app, to ensure all changes are written every minute or so. Remember to
add BDE (or was it DbiProcs in D2?) in uses clause:

procedure TFrmMain.SaveDBChangesTimerTimer(Sender: TObject);
var
  currStatus: string;
  I,j: Integer;
begin
  for i := 0 to Screen.FormCount-1 do
    for j := 0 to Screen.Forms[i].ComponentCount - 1 do
     if (Screen.Forms[i].Components[j] is TTable) then begin
      with  Screen.Forms[i].Components[j] as TTable do
        if Active then
          DbiSaveChanges(Handle);
     end;
end;

... it forces all tables of all forms to be written, if unsaved changes exist, and is controlled by
a timer. Remember to disable the timer when performing tasks that would interfer with this saving
(e.g. large blocks of deletes/inserts/updates).

Good luck !

--

Bjoerge

Other Threads