我有两个button,一个是'删除记录,'一个是'刷新',当我删除完一个选定的记录后,再一刷新,本应删除的记录又出现了,我的代码如下:procedure Txinxishow.bsSkinButton2Click(Sender: TObject);
begin
if messagebox(0,'确认要删除?','信息提示!',mb_yesno+mb_iconinformation+mb_taskmodal)=idyes then
adoquery1.Delete;
end;
procedure Txinxishow.bsSkinButton4Click(Sender: TObject);
beginadoquery1.Close;
adoquery1.Active:=false;
adoquery1.Open;
adoquery1.Active:=true;
end;
begin
if messagebox(0,'确认要删除?','信息提示!',mb_yesno+mb_iconinformation+mb_taskmodal)=idyes then
adoquery1.Delete;
end;
procedure Txinxishow.bsSkinButton4Click(Sender: TObject);
beginadoquery1.Close;
adoquery1.Active:=false;
adoquery1.Open;
adoquery1.Active:=true;
end;
adoquery1.UpdateBatch
那么执行删除后要提交:
adoquery1.UpdateBatch
因為你是緩存的方式
delete:
adoquery1.delete;
adoquery1.UpdateBatch
post:
if AdoQuery1.state in [dsInsert,dsEdit] then AdoQuery1.post;
adoquery1.UpdateBatch; 刪除或保存後一定要將緩存中的數據 updatebatch 到數據庫
procedure Txinxishow.bsSkinButton2Click(Sender: TObject);
begin
if messagebox(0,'确认要删除?','信息提示!',mb_yesno+mb_iconinformation+mb_taskmodal)=idyes then
adoquery1.Delete;
AdoQuery.Post;
end;