我想实现的功能是这样的:比如按工号搜索,如过没有这条数据,那就显示个MESSAGEBOX,数据集如果搜不到数据能返回什么条件?我这里应该怎么写呀?if Edit1.Text='工号' then
  begin
  MainForm.ADOTable1.Filter:= Format('ID=%s', [vartostr(edtFind.Text)]);
    if  ???? then
  Application.MessageBox('很遗憾,没有找到:(','提示',MB_OK+MB_ICONMASK);
  end  按照我这里的写法执行不到messagebox 这一句,在上面就已经停掉了,那怎么半呀??
高手指教啊~~  多谢!

解决方案 »

  1.   

    用locate来定位,如果结果是true那么找到,否则就弹出信息;
    或者你这样,设置一个变量,当找到对应信息时候,变量为2,最后判断变量是否等于2,根据结果看是否需要弹出信息!
      

  2.   

    ADOQuery
      select [column] from [table] where [column]= :[value]Delphi
      if [column]=null
      then messagebox...
      

  3.   

    var found:boolean;
    begin
    found:=MainForm.ADOQuery1.Locate(字段名,要查找的值,[loPartialKey,loCaseInsensitive]);
    if not found then
      begin
        MessageBox('很遗憾,没有找到:(','提示',MB_OK+MB_ICONMASK);
      end;