with clientdataset  do
begin
  append;
  FieldByName('names').AsString:=names;
  .....  Fieldbyname('id').AsInteger:=id;
  post;  if changecount>0 then
  begin
   objMaint.Uplate(delta,nErr);//Uplate定义在业务类TMaint中,objMaint为类TMaint的一个实例
  if nErr>0 then
   application.MessageBox('添加失败!',M_TITLE,MB_ICONWARNING)
   else
   application.MessageBox('添加成功!',M_TITLE,MB_ICONINFORMATION);
   end;
end;procedure TMaint.Uplate(data :olevariant;out ErrCount:integer);
begin
 with DM do
 begin
   DataSetProvider.ApplyUpdates(data,0,ErrCount);
 end;
end;
代码如上,请高手指点!

解决方案 »

  1.   

    DataSetProvider.ApplyUpdates(data,0,ErrCount);
    改為:
    clientdataset.ApplyUpdate(0);
      

  2.   

    to:aiirii(ari-爱的眼睛) 
    您的意思是直接用clientdataset.ApplyUpdate,不用DataSetProvider.ApplyUpdates?
    我改为下面这样,却提示数据集丢失,为何?
    with clientdataset  do
    begin
      append;
      FieldByName('names').AsString:=names;
      .....  Fieldbyname('id').AsInteger:=id;
      post;  if changecount>0 then
      begin
       nErr:=ApplyUpdate(0);//********************改为这样
      if nErr>0 then
       application.MessageBox('添加失败!',M_TITLE,MB_ICONWARNING)
       else
       application.MessageBox('添加成功!',M_TITLE,MB_ICONINFORMATION);
       end;
    end;
      

  3.   

    自己解决了!我的代码没有问题,我忘记设置DataSetProvider.ResolveToDataSet=true和
    Query.RequestLive=true了。