在循环操作数据库时,跳出当前循环遇到问题。下面的DkLowTs变量值是30,查询出来ts字段中有31   32   29  28  31,在执行了29的时候,使用continue,之后的 就都不会再执行了。
 with ADOQuery1 do
  begin
      first;
         for i := 0 to RecordCount-1 do
       begin            ts:=fieldbyname('ts').AsInteger;            if StrToInt(DkLowTs)>ts then continue;  //用了 continue;来判断条件后,总个过程都会跳出。 
            
            …… 后面是插入数据库的代码
       Next;
       end;
   end;

解决方案 »

  1.   

    用while not ADOQuery1 .eof  试试
      

  2.   

    if StrToInt(DkLowTs)>ts then
    begin
      next;
      continue;
    end;不加next,就会死循环。
      

  3.   


    我代码中不是有条件么?if StrToInt(DkLowTs)>ts then continue; //用了 continue;来判断条件后,总个过程都会跳出。  
      

  4.   

    己搞定,谢谢大家,不要用跳出当前循环,直接用if biegn end把后面的括进去就能解决了。谢谢二楼。