and clearing the cache when the operation is successful. 清除CACHE区数据,即状态标志
The following procedure illustrates how to apply a dataset抯 cached updates to a database in response to a button click:procedure TForm1.ApplyButtonClick(Sender: TObject);begin with CustomerQuery do begin Database1.StartTransaction; try ApplyUpdates; {try to write the updates to the database}; Database1.Commit; {on success, commit the changes}; except Database1.Rollback; {on failure, undo the changes}; raise; {raise the exception to prevent a call to CommitUpdates!} end; CommitUpdates; {on success, clear the cache} end;end;
and clearing the cache when the operation is successful. 清除CACHE区数据,即状态标志
with CustomerQuery do
begin
Database1.StartTransaction;
try
ApplyUpdates; {try to write the updates to the database};
Database1.Commit; {on success, commit the changes};
except
Database1.Rollback; {on failure, undo the changes};
raise; {raise the exception to prevent a call to CommitUpdates!}
end;
CommitUpdates; {on success, clear the cache}
end;end;