D
dgn
Unregistered / Unconfirmed
GUEST, unregistred user!
var i:integer;
ErrorCount:integer;
sql:string;
begin
ErrorCount:=0;
SocketConnection1.Connected:=true;
SocketConnection1.AppServer.begin
trans;
dataset1.close;
dataset1.CommandText:='select * from easetd';
dataset1.Open;
for i:=1 to dataset1.RecordCountdo
begin
sql:='insert into test(tdh)' ;
sql:=sql+' values('+''''+dataset1.fieldbyname('提单号').AsString+''''+')';
dataset2.Close;
dataset2.CommandText:=sql;
try
dataset2.Execute;
inc(ErrorCount);
dataset1.MoveBy(1);
except
ErrorCount:=0;
break;
end;
end;
if ErrorCount>0 then
SocketConnection1.AppServer.RollBack
else
SocketConnection1.AppServer.committran;
SocketConnection1.Connected:=false;
dataset1.close;
dataset2.close;
end;
意图,除非所有记录正确添加入数据库,否则提交取消
运行这行命令时出现以下错误信息:
'method 'begin
trans' not supported by automation object'
另外这样处理行得通吗,如不行请如何实现
ErrorCount:integer;
sql:string;
begin
ErrorCount:=0;
SocketConnection1.Connected:=true;
SocketConnection1.AppServer.begin
trans;
dataset1.close;
dataset1.CommandText:='select * from easetd';
dataset1.Open;
for i:=1 to dataset1.RecordCountdo
begin
sql:='insert into test(tdh)' ;
sql:=sql+' values('+''''+dataset1.fieldbyname('提单号').AsString+''''+')';
dataset2.Close;
dataset2.CommandText:=sql;
try
dataset2.Execute;
inc(ErrorCount);
dataset1.MoveBy(1);
except
ErrorCount:=0;
break;
end;
end;
if ErrorCount>0 then
SocketConnection1.AppServer.RollBack
else
SocketConnection1.AppServer.committran;
SocketConnection1.Connected:=false;
dataset1.close;
dataset2.close;
end;
意图,除非所有记录正确添加入数据库,否则提交取消
运行这行命令时出现以下错误信息:
'method 'begin
trans' not supported by automation object'
另外这样处理行得通吗,如不行请如何实现