J
jesse-zxw
Unregistered / Unconfirmed
GUEST, unregistred user!
客户:
var avflag:variant;
begin
if clientdataset1.State in [dsedit,dsinsert] then
clientdataset1.Post;
dcomconnection1.AppServer.updatedata(clientdataset1.Delta,avflag);
if avflag then
showmessage('ok')
else
showmessage('not ok');
end;
服务端:
procedure Ttestcom.updatedata(var data1: OleVariant;
out avflag: OleVariant);
var
updataset:Tclientdataset;
adoquery:Tadoquery;
begin
//form1.DataSource1.DataSet:=data1;
updataset.Data:=data1;
if not updataset.IsEmpty then
begin
avflag:=true;
while not updataset.Eofdo
case updataset.UpdateStatus of
usModified:
begin
try
adoquery:=tadoquery.Create(nil);
adoquery.Connection:=adoconnection1;
adoquery.EnableBCD:=false;
adoquery.SQL.Add('update dept set dept_name=:dept_name where dept_id=:dept_id');
adoquery.Parameters.ParamValues['dept_name']:=updataset.FieldValues['dept_name'];
adoquery.Parameters.ParamValues['dept_id']:=updataset.FieldValues['dept_id'];
adoquery.Prepared;
try
adoquery.ExecSQL;
except
avflag:=false;
exit;
end;
finally
adoquery:=nil;
end;
end;
end;
end;
end;
进行修改时,提示"灾难性错误"!不知是何原因,只有14分,不够以后再加呀
var avflag:variant;
begin
if clientdataset1.State in [dsedit,dsinsert] then
clientdataset1.Post;
dcomconnection1.AppServer.updatedata(clientdataset1.Delta,avflag);
if avflag then
showmessage('ok')
else
showmessage('not ok');
end;
服务端:
procedure Ttestcom.updatedata(var data1: OleVariant;
out avflag: OleVariant);
var
updataset:Tclientdataset;
adoquery:Tadoquery;
begin
//form1.DataSource1.DataSet:=data1;
updataset.Data:=data1;
if not updataset.IsEmpty then
begin
avflag:=true;
while not updataset.Eofdo
case updataset.UpdateStatus of
usModified:
begin
try
adoquery:=tadoquery.Create(nil);
adoquery.Connection:=adoconnection1;
adoquery.EnableBCD:=false;
adoquery.SQL.Add('update dept set dept_name=:dept_name where dept_id=:dept_id');
adoquery.Parameters.ParamValues['dept_name']:=updataset.FieldValues['dept_name'];
adoquery.Parameters.ParamValues['dept_id']:=updataset.FieldValues['dept_id'];
adoquery.Prepared;
try
adoquery.ExecSQL;
except
avflag:=false;
exit;
end;
finally
adoquery:=nil;
end;
end;
end;
end;
end;
进行修改时,提示"灾难性错误"!不知是何原因,只有14分,不够以后再加呀