• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 854
  • Last Modified:

TTable AfterPost Event, BDE, Delphi 2009

Hello,

  I still use the BDE over Delphi 2009, Paradox Tables.

   if a database or a table is local on a PC installed (Paradox or Dbase) and the BDE-setting
"LOCAL SHARE" is FALSE, then changings are not stored immediatly but are kept in the memory.
This changings are gone after a crash.

  So I got an idea from a website, it says that I should write the below code to force BDE to Store changes to the table.

  in my  application which have more than 100 forms, and more than 70 tables, If I want to do this for all Tables It will take time coding.

 My Question is: is there any windows Message I can trap, so I can tell the Application to run the below code when OnPost event happens for all tables in my application.
procedure TForm1.Table1AfterPost(DataSet:TDataSet);
begin
  DbiSaveChanges(Table1.Handle);
end;

Open in new window

0
i7mad
Asked:
i7mad
  • 3
  • 2
1 Solution
 
Geert GruwezOracle dbaCommented:
My 2 cents:
big application, just consider updating the database too ...
you updated to the latest Delphi version

here is a possible solution procedure to call:
procedure TForm1.SaveAllTables;
var I, J, K: Integer;
  D: TDBDataset;
begin
  for I := 0 to Sessions.Count-1 do
    for J := 0 to Sessions[I].DatabaseCount-1 do
      for K := 0 to Sessions[I].Databases[J].DataSetCount-1 do
      begin
        D := Sessions[I].Databases[J].DataSets[K];
        if D is TTable then
          DbiSaveChanges(TTable(D).Handle);
      end;
end;

Open in new window

0
 
i7madAuthor Commented:
Thanks Geert_Gruwez

  So I should call this procedure before Application.Terminate, or I think on Main form Destroy event?
0
 
i7madAuthor Commented:
Thanks.
0
 
Geert GruwezOracle dbaCommented:
i7mad,
i would call it in the OnClose of the mainform
this way the applications hasn't freed all the objects yet
in the ondestroy it's possible some objects/tables got destroyed/freed allready.

G
0
 
i7madAuthor Commented:
Thanks.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now