公用一个ADOQuery和DataSetProvider来更新单个数据表的更新:
1.DataSetProvider的Exported设为True,ResolvetoDateSet设为True;
增加DataSetProvider的OnApplyUpdates事件处理:
procedure TMyRDM.DataSetProvider1BeforeApplyUpdates(Sender: TObject;
var OwnerData: OleVariant);
begin
with ADOQuery1do
begin
Close;
SQL.Clear;
SQL.Add(VarToStr(OwnerData));
Open;
end;
end;
客户端更新代码:
var
ErrorCount:Integer;
OwnerData:OleVariant;
begin
OwnerData:='SELECT TOP 0 * FROM Table1';
ClientDataSet1.AppServer.AS_ApplyUpdates('DataSetProvider1',ClientDataSet1.Delta,0,ErrorCount,OwnerData);
OwnerData:='SELECT TOP 0 * FROM Table2';
ClientDataSet2.AppServer.AS_ApplyUpdates('DataSetProvider1',ClientDataSet2.Delta,0,ErrorCount,OwnerData);
end;