这是从客户端传来数组然后处理后又传回客户端的,你试试: function TVoiceSys.ApplyUpdateS(var Data: OleVariant; Provider: OleVariant; ArrayLength: Integer): Integer; Var TmpPro:TDataSetProvider; i:Word; Pro:String ; begin cn.BeginTrans; Try for i:= 0 to ArrayLength-1 do begin TmpPro := TDataSetProvider(FindComponent(Provider[i])); Pro:=TmpPro.Name; if (TmpPro<>nil) and (not VarIsNull(Data[i])) then begin TmpPro.ApplyUpdates(Data[i],0,Result); if Result>0 then Abort; end; end; Result := 0; Cn.CommitTrans ; Except Cn.RollbackTrans; end; end; 客户端代码 procedure aSaveExecute(Sender: TObject); var ZbVar,MxVar:OleVariant; ResultS:Integer; Re:OleVariant; begin dsMx.CheckBrowseMode; dsZb.CheckBrowseMode; if dsZb.ChangeCount >0 then ZbVar := dsZb.Delta else ZbVar := NULL; if dsMx.ChangeCount >0 then MxVar := dsMx.Delta else MxVar := NULL; Re := VarArrayOf([ZbVar,MxVar]); ResultS := dsZb.RemoteServer.AppServer.ApplyUpdateS(Re,VarArrayOf([dsZb.ProviderName,dsMx.ProviderName]),2); if not VarIsNull(Re[1]) then dsMx.Reconcile(Re[1]) else if not VarIsNull(Re[0]) then dsZb.Reconcile(Re[0]) else begin dsMx.Reconcile(Re[1]); dsZb.Reconcile(Re[0]); dsMx.Refresh; dsZb.Refresh; end; end;
function TVoiceSys.ApplyUpdateS(var Data: OleVariant; Provider: OleVariant;
ArrayLength: Integer): Integer;
Var
TmpPro:TDataSetProvider;
i:Word;
Pro:String ;
begin
cn.BeginTrans;
Try
for i:= 0 to ArrayLength-1 do
begin
TmpPro := TDataSetProvider(FindComponent(Provider[i]));
Pro:=TmpPro.Name;
if (TmpPro<>nil) and (not VarIsNull(Data[i])) then
begin
TmpPro.ApplyUpdates(Data[i],0,Result);
if Result>0 then
Abort;
end;
end;
Result := 0;
Cn.CommitTrans ;
Except
Cn.RollbackTrans;
end;
end;
客户端代码
procedure aSaveExecute(Sender: TObject);
var
ZbVar,MxVar:OleVariant;
ResultS:Integer;
Re:OleVariant;
begin
dsMx.CheckBrowseMode;
dsZb.CheckBrowseMode;
if dsZb.ChangeCount >0 then
ZbVar := dsZb.Delta
else
ZbVar := NULL;
if dsMx.ChangeCount >0 then
MxVar := dsMx.Delta
else
MxVar := NULL;
Re := VarArrayOf([ZbVar,MxVar]);
ResultS := dsZb.RemoteServer.AppServer.ApplyUpdateS(Re,VarArrayOf([dsZb.ProviderName,dsMx.ProviderName]),2);
if not VarIsNull(Re[1]) then
dsMx.Reconcile(Re[1])
else
if not VarIsNull(Re[0]) then
dsZb.Reconcile(Re[0])
else
begin
dsMx.Reconcile(Re[1]);
dsZb.Reconcile(Re[0]);
dsMx.Refresh;
dsZb.Refresh;
end;
end;
如下,创建一个二维数据并赋值:
var
vArray: OleVariant;
begin
vArray:= VarArrayCreate([0, 1, 0, 2], varVariant);
vArray[0, 0] := 'aaa';
vArray[0, 1] := 1;
vArray[0, 2] := 'bbb';
vArray[1, 0] := 'ccc';
vArray[1, 1] := 2;
vArray[1, 2] := 'ddd';
end;
dsMx.Reconcile(Re[1]);
楼主就用这个方法没错