为什么下面的代码,不是修改记录,而是添加记录,请各位帮忙解决,谢谢
procedure TForm1.Button11Click(Sender: TObject);
var
i:integer;
begin
if dbgrid1.selectedrows.count=1 then
  begin
  if application.MessageBox(pchar('是否修改你选定的记录?'),'删除否?',mb_yesno+MB_defbutton2)=id_yes then
  begin
   with dbgrid1. datasource.DataSet do
     for i:=0 to dbgrid1.selectedrows.Count-1 do
       begin
        gotobookmark(pointer(dbgrid1.SelectedRows.items[i]));
          if dbgrid1.fields[0].asstring=edit8.text then
            begin
with adoquery1 do
begin
close;
sql.clear;
sql.add('select * from info where age='''+edit9.text+'''');
open;
end;

if adoquery1.RecordCount>0 then
begin
showmessage('存在age');
exit;
end;
adoquery1.Edit;
ADOQuery1.fieldbyname('name').asstring:=edit8.Text;
ADOQuery1.fieldbyname('age').asstring:=edit9.Text;
ADOQuery1.fieldbyname('sex').asstring:=combobox12.Text;
adoquery1.post;
end
else
showmessage('你要修改name!');
end;
end
else
showmessage('你不修改任何记录!');
end
else
showmessage('请选择一条记录进行修改');
end;