我用的是ACCESS数据库。
为什么只能调用两次,只要调用次数达到三次或三次以上就会出错!!
procedure TddwhForm.DBGrid2KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
  begin
  if ((floattostr(adoquery2.FieldByName('price').AsFloat) <> '') and ((inttostr(adoquery2.FieldByName('sl').AsInteger) <> '')))then
     begin
     adoquery2.Edit;
     adoquery2.FieldByName('total').AsFloat:= adoquery2.FieldByName('price').AsFloat *  adoquery2.FieldByName('sl').AsInteger
     end;
     Adoquery2.Post;
     showmessage('修改成功!');
  end;
end;
end.出错提示:
project CFproject.ext raised exception class EOleException with message'key column information is insufficient or incorrect.Too many 
rows were affected by update'。

解决方案 »

  1.   

    存在相同的记录行、用”Edit”修正時会出Error
      

  2.   

    你的库中出现了相同的记录啊,在update时更新影响到了多行,可能你没有设主键
      

  3.   

    Too many rows were affected by update.......................
    去库里先删除掉相同的多条记录吧。
      

  4.   

    hmily1688(刘涛--公司里面打杂的) 
    对啊,我没有设置主键,我必需不主键啊因为我需要在里面存贮相同的记录,
      

  5.   

    procedure TddwhForm.DBGrid2KeyPress(Sender: TObject; var Key: Char);
    begin
      if key=#13 then
      begin
      if ((floattostr(adoquery2.FieldByName('price').AsFloat) <> '') and ((inttostr(adoquery2.FieldByName('sl').AsInteger) <> '')))then
         begin
         adoquery2.Edit;
         adoquery2.FieldByName('total').AsFloat:= adoquery2.FieldByName('price').AsFloat *  adoquery2.FieldByName('sl').AsInteger
         end;
         Adoquery2.Post;
         showmessage('修改成功!');
      end;
    end;