我用的是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'。
为什么只能调用两次,只要调用次数达到三次或三次以上就会出错!!
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'。
去库里先删除掉相同的多条记录吧。
对啊,我没有设置主键,我必需不主键啊因为我需要在里面存贮相同的记录,
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;