A
awfigsk
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TSalesServerCK.ProductViewDSPBeforeUpdateRecord(Sender: TObject;
SourceDS: TDataSet;
DeltaDS: TCustomClientDataSet;
UpdateKind: TUpdateKind;
var Applied: Boolean);
begin
var
TmpQry:TADOQuery;
TmpConn:TADOConnection;
TmpCode:String;
begin
try
TmpQry:=TADOQuery.Create(nil);
TmpConn:=TADOConnection.Create(nil);
TmpConn.ConnectionString:=...;
TmpConn.LoginPrompt:=False;
TmpConn.Connected:=True;
TmpQry.Connection:=TmpConn;
DeltaDS.First;
while not DeltaDS.Eofdo
begin
TmpCode:=DeltaDS.FieldByname('Code').AsString;
TmpQry.SQL.Text:='Update Test set id='+Tmpcode;
TmpQry.ExecSQL;
DeltaDS.Next
end;
Applied:=False;
finally
FreeAndNil(TmpQry);
FreeAndNil(TmpConn);
end;
end;
我在DataSetProvider的BeforeUpdateRecord事件中加了上述代码后,客户端ApplyUpdates(0)就不能更新数据表了。如果将上述代码去掉,则在客户端ApplyUpdates(0)就可以更新数据表。这是为何?上述代码我并没有对Delta数据进行操作呀?
我利用SQL事件跟踪器发现在上述更新语句执行,会插入一个
if @@TransCount>0 RollBack Tran
SourceDS: TDataSet;
DeltaDS: TCustomClientDataSet;
UpdateKind: TUpdateKind;
var Applied: Boolean);
begin
var
TmpQry:TADOQuery;
TmpConn:TADOConnection;
TmpCode:String;
begin
try
TmpQry:=TADOQuery.Create(nil);
TmpConn:=TADOConnection.Create(nil);
TmpConn.ConnectionString:=...;
TmpConn.LoginPrompt:=False;
TmpConn.Connected:=True;
TmpQry.Connection:=TmpConn;
DeltaDS.First;
while not DeltaDS.Eofdo
begin
TmpCode:=DeltaDS.FieldByname('Code').AsString;
TmpQry.SQL.Text:='Update Test set id='+Tmpcode;
TmpQry.ExecSQL;
DeltaDS.Next
end;
Applied:=False;
finally
FreeAndNil(TmpQry);
FreeAndNil(TmpConn);
end;
end;
我在DataSetProvider的BeforeUpdateRecord事件中加了上述代码后,客户端ApplyUpdates(0)就不能更新数据表了。如果将上述代码去掉,则在客户端ApplyUpdates(0)就可以更新数据表。这是为何?上述代码我并没有对Delta数据进行操作呀?
我利用SQL事件跟踪器发现在上述更新语句执行,会插入一个
if @@TransCount>0 RollBack Tran