删除前的判断。
procedure TForm1.Button8Click(Sender: TObject);
var
SQLL:string;
begin
if DBGridEh2.DataSource.DataSet=nil then
begin
showmessage('没有可删除数据!');
end
else
begin
SQLL:='delete from Checke where Dormitory='''+DBGridEh2.Columns.Grid.Fields[0].Value+'''';
if application.MessageBox('是否要删除此信息!','提示',mb_yesno)=idyes then
begin
with ADOQuery1 do
begin
SQL.Clear;
Close;
SQL.Add('select * from Dormitory where Dormitory= '''+DBGridEh2.Columns.Grid.Fields[0].Value+''''); ---这里报错。
Open;
end;
if ADOQuery1.RecordCount>0 then
begin
showmessage('操作失败!');
exit;
end
else
begin
Form1.shuaixi(DBGridEh2,DBGridEh1,DBGridEh3,DBGridEh4);
end;
end;
end;
end;