if not QueryCopyDataFlag(sPicName) then //没拷贝
        begin
          for i:=1 to 3 do //3个表
          begin
            sSQL:='insert into  tb_Data_'+inttostr(i)+'_5 select * from  tb_Data_'+inttostr(i)+'_4'+
              ' where batchName='+Quotedstr(CurrBatchName)+' and PicName='+Quotedstr(sPicName);
            if not ExecSQLString(sSQL) then
            begin
              TDBConnector.Instance.Connection.RollbackTrans;
              Exit;
            end;
          end;
          sSQL:='update TB_Picture set Status5=1, Begin5='+ QuotedStr(DateTimeToStr(sDate))+',User5='+
          QuotedStr(TLoginUser.Instance.UserID)+' where BatchName='+QuotedStr(CurrBatchName)+'and PicName='+Quotedstr(sPicName);
          if not ExecSQLString(sSQL) then
          begin
            TDBConnector.Instance.Connection.RollbackTrans;
            Exit;
          end;
        end;
        next
      end;//end while
      Close;
    finally
      Free;
    end;
  end;

解决方案 »

  1.   

    if not QueryCopyDataFlag(sPicName) then 
    这有什么解释的如果 QueryCopyDataFlag(sPicName) 返回不为真 则执行下面的程序
      

  2.   


      if not QueryCopyDataFlag(sPicName) then //没拷贝 
            begin 
              for i:=1 to 3 do //3个表 
              begin 
                sSQL:='insert into  tb_Data_'+inttostr(i)+'_5 select * from  tb_Data_'+inttostr(i)+'_4'+ 
                  ' where batchName='+Quotedstr(CurrBatchName)+' and PicName='+Quotedstr(sPicName);    //插入数据
                if not ExecSQLString(sSQL) then //如果执行失败
                begin 
                  TDBConnector.Instance.Connection.RollbackTrans; //回滚事务
                  Exit; 
                end; 
              end; 
              sSQL:='update TB_Picture set Status5=1, Begin5='+ QuotedStr(DateTimeToStr(sDate))+',User5='+ 
              QuotedStr(TLoginUser.Instance.UserID)+' where BatchName='+QuotedStr(CurrBatchName)+'and PicName='+Quotedstr(sPicName);  //更新TB_Picture
              if not ExecSQLString(sSQL) then //如果执行不成功
              begin 
                TDBConnector.Instance.Connection.RollbackTrans; //回滚事务
                Exit; 
              end; 
            end; 
            next 
          end;//end while 
          Close; 
        finally 
          Free; 
        end; 
      end;
      

  3.   

     TDBConnector.Instance.Connection.RollbackTrans; //回滚事务
                  Exit; 
                end; 
              end; 
              sSQL:='update TB_Picture set Status5=1, Begin5='+ QuotedStr(DateTimeToStr(sDate))       +',User5='+ 
              QuotedStr(TLoginUser.Instance.UserID)+' where BatchName='+QuotedStr(CurrBatchName)+'and PicName='+Quotedstr(sPicName);  //更新TB_Picture
              if not ExecSQLString(sSQL) then //如果执行不成功
              begin 
                TDBConnector.Instance.Connection.RollbackTrans; //回滚事务                     
                Exit; 那怎么在回滚事物中还有个sql语句是干吗的
      

  4.   

    sSQL:='update TB_Picture set Status5=1, Begin5='+ QuotedStr(DateTimeToStr(sDate))+',User5='+ 
              QuotedStr(TLoginUser.Instance.UserID)+' where BatchName='+QuotedStr(CurrBatchName)+'and PicName='+Quotedstr(sPicName);  //更新TB_Picture
    应该是更改状态的;第一个回滚只是 针对上一个SQL语句的处理,即'insert into  tb_Data_'+inttostr(i)+'_5 select * from  tb_Data_'+inttostr(i)+'_4'+ 
                  ' where batchName='+Quotedstr(CurrBatchName)+' and PicName='+Quotedstr(sPicName);    它与后边的无关