求助,list index out of bound(1)!!但程序运行的结果还是正确的
那位高手进来帮解决一下啊,我很菜,遇到这问题都弄了半天,我实在搞不懂那地方越界了啊,下面是我的源码
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
if DBGrid1.selectedrows.Count > 0 then
with DBGrid1.datasource.dataset do
begin
for i := 0 to DBGrid1.selectedrows.count - 1 do
begin
gotobookmark(pointer(DBGrid1.selectedrows.items[i]));
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('update yh set id='''+Edit2.text+''' where name=:name');
Parameters.ParamByName('name').Value:=trim(Edit1.Text);
try
ExecSql;
except
MessageDlg('数据更新失败!',mtError,[mbYes],0);
exit;
end;
end
end;
end;
end;
end.