我一条一条删除一个表中的记录,代码如下:
whiele not adodataset1.eof do
begin
  delete;
  next;
end;
  问题是:当adodataset1中的记录没空值时,正常。一但某值为空,就显示:adodataset1:not in edit or insert mode.这意思我懂,是说adodataset1不在编辑或插入模式这下。可这是删除呀,匡切在没空值时正常。请老大帮忙。

解决方案 »

  1.   

    哦,对了,代码中,没有next;因为不需要。问题还是上边的问题
      

  2.   

    *********************************************************************************
    问题是:当adodataset1中的记录没空值时,正常。一但某值为空,就显示:adodataset1:not in edit or insert mode.这意思我懂,是说adodataset1不在编辑或插入模式这下。可这是删除呀,匡切在没空值时正常。请老大帮忙。
    *********************************************************************************
    “某值为空”  什么意思?
    是记录为空?  还是一条记录的某个字段为空?
      

  3.   

    我试了一下 没问题
    估计是你的数据库的那个字段不允许为空吧while not adodataset1.eof do
    begin
      delete;
    end;
      

  4.   

    在删除前加个判断就OK啦.
    if (active = false) or (recordcount = 0) then 
    showmessage('记录为空,不能删除操作!');
      

  5.   

    whiele not adodataset1.eof do
    begin
      delete;
      next;
    end;
    改成这样看看
    whiele not adodataset1.eof do
    begin
      delete;
    end;
      

  6.   

    每删除一条之后判断一下,recordcount 大于 0时继续,反之跳出
      

  7.   

    whiele not adodataset1.eof do
    begin
      If AdoDataSet1.RecordCount<=0 then
         Break;
      delete;
    end;
      

  8.   

    with ADOQry do begin
                Close;
                Sql.Clear;
                sql.Add ('Delete * from DataDict ');
                ExecSQL ;
     end;
      

  9.   

    有bug,调试一下具体是那里出现问题
      

  10.   

    最好不要这么写  delete 最好后面加条件 比方delete * from DataDict where xxxx
     要想清空表 用turncate table xx这样安全也快得多
      

  11.   

    if adodataset1.Active then //如果数据集打开就执行下面的操作
      whiele not adodataset1.eof do
      begin
        delete;
      end;
      

  12.   

    delete 没用的记录,然后刷新