I have to write several records at once in the database, I am using the form below, however I think giving applyupdate to every interaction is not the correct way. Is there another way?
procedure TFrm.Button1Click(Sender: TObject);
Var
i: Integer;
begin
(ds.DataSet as TClientdataset).Open;
For i := 1 to 10 do
begin
(ds.DataSet as TClientdataset).Insert;
ds.DataSet.FieldByName('med1').AsInteger:= 1;
ds.DataSet.FieldByName('med2').AsInteger:= 1;
ds.DataSet.FieldByName('med3').AsInteger:= 2;
ds.DataSet.FieldByName('med4').AsDateTime:= Now;
ds.DataSet.FieldByName('med5').AsFloat:= 1;
ds.DataSet.FieldByName('med6').AsDateTime:= Now;
(ds.DataSet as TClientdataset).Post;
(ds.DataSet as TClientdataset).ApplyUpdates(0);
end;
end;