我在一个begintrain 中开始事务处理,在一个选环中,对几个表操作,最后commit,但是commit是报错:“no user transaction is currently in process ”的错误,不能运行??为什么
gs.StartTransaction;
for I:=1 to Query2.RecordCount do
begin
if Query2.FieldByName('0').asinteger= 0 then
Query2.Next
else
begin
Query_temp.close;
Query_temp.SQL.clear;
Query_temp.SQl.Add(IUpsql);
Query_temp.ParamByName('tt').asstring:=guoh;
Query_temp.ExecSQL;
if Query_temp.RowsAffected=0 then
begin
Query4.close;
Query4.SQl.clear;
Query4.SQl.Add(IINSQl);
Query4.ParamByName('Piaodgh').asstring:=guoh
Query4.ExecSQL;
end;
Query4.Close;
Query4.SQL.Clear;
Query4.SQL.Add(ISQlUp);
Query4.ParamByName('pishu').asinteger:=Sum_PiShuo
Query4.ExecSQL;
Query2.Next;
end;
end
gdbs.Commit;
gs.StartTransaction;
for I:=1 to Query2.RecordCount do
begin
if Query2.FieldByName('0').asinteger= 0 then
Query2.Next
else
begin
Query_temp.close;
Query_temp.SQL.clear;
Query_temp.SQl.Add(IUpsql);
Query_temp.ParamByName('tt').asstring:=guoh;
Query_temp.ExecSQL;
if Query_temp.RowsAffected=0 then
begin
Query4.close;
Query4.SQl.clear;
Query4.SQl.Add(IINSQl);
Query4.ParamByName('Piaodgh').asstring:=guoh
Query4.ExecSQL;
end;
Query4.Close;
Query4.SQL.Clear;
Query4.SQL.Add(ISQlUp);
Query4.ParamByName('pishu').asinteger:=Sum_PiShuo
Query4.ExecSQL;
Query2.Next;
end;
end
gdbs.Commit;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货