为什么提示:adq1:dataset not in edit or insert mode
procedure TForm1.Button1Click(Sender: TObject);
begin
while not adq1.Eof do
begin
if  (leftstr(adq1hm.Value,2)<>'13') or (leftstr(adq1hm.Value,2)<>'86') then
   begin
    adq1.Edit;
    adq1.Delete;
    adq1.post;
  end;
adq1.Next;
end;
  end;
想去掉以13或86开头的记录。

解决方案 »

  1.   

    with adq1 do 
    begin 
       close;
       sql.text := ' delete from table where (col1 like '13%' or col1 like '86%')';
       execsql;
    end;直接用SQL语句删除不好吗?
      

  2.   

    adq1是什么?Adoquery吗?
    试试在adq1.Edit; 前面加个Adq1.open先··
      

  3.   


    为什么提示:adq1:dataset not in edit or insert mode 
    procedure TForm1.Button1Click(Sender: TObject); 
    begin 
    while not adq1.Eof do 
    begin 
      //if  (leftstr(adq1hm.Value,2) <>'13') or (leftstr(adq1hm.Value,2) <>'86') then 
      if  (leftstr(adq1hm.Value,2) ='13') or (leftstr(adq1hm.Value,2) ='86')
      begin 
        //adq1.Edit; 
        adq1.Delete; 
        //adq1.post; 
      end; 
      adq1.Next; 
    end; 
      end; 
    想去掉以13或86开头的记录。 
     你的算法與你要的結果好像不一樣。
      

  4.   

    你用while not adq1.Eof do  最好在前面加个adq1.First; 记录指针有可能不在第一个
      

  5.   


        adq1.Edit; 
       
        adq1.post;
    用来修改的