with InsertQry do begin
    Close;
    Sql.Clear;
    sql.Text := 'select * from AB where times='+trim(edit1.Text);
    open;
end;
if InsertQry.RecordCount>0 then begin
    with InsertQry do begin
    Close;
    Sql.Clear;
    sql.Text := 'delete * from AB where times='+trim(edit1.Text); //执行这一句为何报错啊
    open;
    end;
end;

解决方案 »

  1.   

    with InsertQry do begin
        Close;
        Sql.Clear;
        sql.add('select * from AB where times='+trim(edit1.Text));
        open;
    end;
    if InsertQry.RecordCount>0 then begin
        with InsertQry do begin
        Close;
        Sql.Clear;
        sql.add('delete * from AB where times='+trim(edit1.Text)); //执行这一句为何报错啊
        execsql;
        end;
    end;
      

  2.   

    引号的问题    with InsertQry do begin
        Close;
        Sql.Clear;
        sql.Text := 'delete * from AB where times='+Quotedstr(trim(edit1.Text)); //      execsql;
        end;
      

  3.   

    引号的问题    with InsertQry do begin
        Close;
        Sql.Clear;
        sql.Text := 'delete * from AB where times='+Quotedstr(trim(edit1.Text)); 
        execsql;
        end;
      
      

  4.   

    或者这样也可```
        with InsertQry do begin
        Close;
        Sql.Clear;
        sql.Text := 'delete * from AB where times='''+(trim(edit1.Text))+'''';    
        execsql;
        end;
      

  5.   

    for i:=1 to InsertQry.RecordCount do begin
            InsertQry.First;
            InsertQry.Delete;
        end;
    我再试一下这样
      

  6.   

    delete 语句 不能用  open;
    用execsql;
      

  7.   

    with InsertQry do begin
        Close;
        Sql.Clear;
        sql.Text := 'select * from AB where times=times='''+trim(edit1.Text)+''' ';
        open;
    end;
    if InsertQry.RecordCount>0 then begin
        with InsertQry do begin
        Close;
        Sql.Clear;
        sql.Text := 'delete * from AB where times='''+trim(edit1.Text)+''' '; 
        execsql;    end;
    end;
      

  8.   

    提示:InsertQry:CommandText does not return a result set有好几个删除操作我这样写都是没有任何问题的,表我重新建了,也一个啊:
    with InsertQry do begin
    Close;
    Sql.Clear;
    sql.Text := 'delete * from A1 where times='+trim(timestimes.Text);
    open;
    end;
    //这里执行删除没有问题with InsertQry do begin
    Close;
    Sql.Clear;
    sql.Text := 'delete * from A2 where times='+trim(timestimes.Text);
    open;
    end;
    //这里执行删除也没有问题with InsertQry do begin
    Close;
    Sql.Clear;
    sql.Text := 'delete * from AB where times='+trim(timestimes.Text);
    open;
    end;
    //这里执行删除就出问题了。
    表和表之单都是独立的,真是搞不懂啊,提示:InsertQry:CommandText does not return a result set
      

  9.   

    hangzhou_hammer() ( ) 信誉:100    Blog  2006-09-18 18:54:00  得分: 0  
     
     
       delete 语句 不能用  open;
    用execsql;
      
     
    谢谢你,你是正确的!!!!多谢!