![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 3 of 3 total |
![]() |
Tue, Oct 3 2017 5:08 AM | Permanent Link |
Paul Coshott | Hi All,
I am using the default Database instance, and need to assign "AfterCommit" and "OnCommitError" event handlers at runtime. Can anyone show me some example code on how to do this? Thanks heaps, Paul |
Tue, Oct 3 2017 7:34 AM | Permanent Link |
Walter Matte Tactical Business Corporation | Hope this gets you going in the right direction ... not tested. If you are using AutoTransactions := False and are doing your won StartTransaction / Commit then you can easily control when you assign these events. If you are using AutoTransactions := True then you will need to decide where to assign the events. In my code I an unassigning the events ... but there are more places to unassign.... AfterRollback and OnRollbackError.... If you add a TDatabase to your unit you can see the events on the TDatabase unit and what arguments are need for each event.... Private procedure MyLocalAfterCommit(Sender: TObject); procedure MyLocalCommitError(Sender: TObject; const ErrorMsg: String); procedure TfrmForm1.MyLocalAfterCommit(Sender: TObject); begin // Code Here Database.AfterCommit := nil; Database.OnCommitError := nil; end; procedure TfrmForm1.MyLocalCommitError(Sender: TObject; const ErrorMsg: String); begin // Code here Database.AfterCommit := nil; Database.OnCommitError := nil; end; Procedure TfrmForm1.Button1Click(Sender : TObject); begin Database.AfterCommit := .MyLocalAfterCommit; Database.OnCommitError := MyLocalCommitError; Database.Commit; end; Walter |
Tue, Oct 3 2017 11:01 PM | Permanent Link |
Paul Coshott | Hi Walter,
Excellent, thanks for the help. Cheers, Paul |
This web page was last updated on Wednesday, March 29, 2023 at 10:59 PM | Privacy Policy![]() © 2023 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |