if ADOQuery1.Locate('id',edit1.text,[])  then
    ShowMessage('find');

解决方案 »

  1.   

    with ADOQuery do
      try
        Close;
        SQL.Clear;
        SQL.Add('select count(*) cnt from table1 where id='+IntToStr(MyID));
        Open;
        if FieldByName('cnt').asInteger>0 then showmessage('存在该ID')
          else showMessage('不存在该ID');
      finally
        Close;
      end
      

  2.   

    to newyj
    有个问题,我不想把表做死,打算写这样的函数:function TfrmProduceEdit.TheFieldIsExit(strCheckedID:string;strTable:string):boolean;strTable即为要访问的表,有很多这样的处理,不可能一个就对应一个query,
      

  3.   

    to Caty :你的方法是一个思路,以前试过,好像是可以的。
      

  4.   

    with dmADO.queryCheckID do begin
              close;
              sql.clear;
              sql.Add ('select ProduceID from ' + strTable + ' where ProduceID=' + strCheckedID);
              open;
              if recordcount>0 then
                   result :=true
              else
                   result :=false;
         end;上面有什么样的问题?
      

  5.   

    先用ADOQuery列出所用纪录
      select * from 表
      if ADOQuery.Locate('ID',ID,[loCaseInsensitive]) then
         有
      else
         无
      

  6.   

    你可以在每次判断之前都select * 一下
      

  7.   

    这些控件又要open,又要close,总是又这样的错误报出。How can I do?
      

  8.   

    Query控件单独使用
    close;
    sql.Add();
    Open;
      

  9.   

    It's OK,在测试之后就开始给分,谢谢各位了!!
      

  10.   

    sorry
     你可以直接填写Query的SQL属性
     每次只需
       Close;
       Open;
      

  11.   

    to wisenowa(h) to others;谢谢你和其他朋友,以后还请多帮忙!
      

  12.   

    to 024h
    你到底明白没有?你的意思我知道,如果不明白的话可以email给我(我有解决的办法)
    [email protected]