Page 1 of 1

CommitUpdates after RestoreUpdates?

Posted: Sun 22 Apr 2007 07:27
by vvitolo
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.

Posted: Mon 23 Apr 2007 13:41
by Antaeus
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.

Posted: Tue 24 Apr 2007 07:37
by vvitolo
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.