CommitUpdates after RestoreUpdates?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
vvitolo
Posts: 10
Joined: Fri 26 Aug 2005 21:45
Location: S/C de Tenerife

CommitUpdates after RestoreUpdates?

Post by vvitolo » Sun 22 Apr 2007 07:27

I've a question about a component TMyTable.
This is the example:
if not Session.InTransaction then
Session.StartTransaction;
TablaMovimientos.Append;
if (frmRecordMovimientos.ShowModal = mrOK) then
begin
Try
TablaMovimientos.Post;
TablaMovimientos.ApplyUpdates;
Session.Commit;
except
if Session.InTransaction then
begin
TablaMovimientos.RestoreUpdates;
Session.Rollback;
raise;
end;
end;
TablaMovimientos.CommitUpdates;
end else
begin
TablaMovimientos.RestoreUpdates;
Session.Rollback;
TablaMovimientos.CommitUpdates;
end;
frmRecordMovimientos.Free;

Is necesary to do CommitUpdates after Roolback?

Thank you for your support.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 23 Apr 2007 13:41

If some button other than "Ok" is pressed in the dialog, and you want to cancel updates made in your dataset, you should call the CancelUpdates method instead of RestoreUpdates and CommitUpdates.

vvitolo
Posts: 10
Joined: Fri 26 Aug 2005 21:45
Location: S/C de Tenerife

Post by vvitolo » Tue 24 Apr 2007 07:37

Antaeus wrote:If some button other than "Ok" is pressed in the dialog, and you want to cancel updates made in your dataset, you should call the CancelUpdates method instead of RestoreUpdates and CommitUpdates.
Thank you for your response.

Post Reply