删除前的判断。
程序代码:
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 Close; SQL.Clear; 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;运行到SQL.Add();这里就报错了。不知道什么原因。