Page 1 of 1
How to modify data before TMSQuery.Apply/Commit
Posted: Mon 24 Oct 2011 07:58
by Lithiumâ„¢
Hello!
Is there any way to modify data in dataset, before Commit(Apply)Updates initiated?
I try use BeforeUpdateExecute(). But all data modifications in this handler are not commited in current commit

. BeforeUpdateExecute intended for Params sets, it's written in help.
Posted: Mon 24 Oct 2011 13:18
by AndreyZ
You can modify a dataset in the BeforeUpdateExecute event handler, but instead of modifying dataset itself, you should modify parameters of an update query. Here is an example:
Code: Select all
procedure TMainForm.BitBtnClick(Sender: TObject);
begin
MSQuery.SQL.Text := 'select * from emp';
MSQuery.Open;
MSQuery.Connection.StartTransaction;
MSQuery.Edit;
MSQuery.FieldByName('sal').AsFloat := 700;
MSQuery.Post;
MSQuery.Connection.Commit;
end;
procedure TMainForm.MSQueryBeforeUpdateExecute(Sender: TCustomMSDataSet;
StatementTypes: TStatementTypes; Params: TMSParams);
begin
if stUpdate in StatementTypes then
Params.ParamByName('sal').AsFloat := 900;
end;
Posted: Tue 25 Oct 2011 05:36
by Lithiumâ„¢
Thanks, it works!

(it seems, I forget this way)
Posted: Tue 25 Oct 2011 07:19
by AndreyZ
Feel free to contact us if you have any further questions about SDAC.