如果我使用adotable控件连接某表,现在我想模糊的查询某字段的内容,请问怎么办
使用locate之类的可以实现么

解决方案 »

  1.   

    var str:string;str := 'filedname = '+'''+'%名%'+''';
    adotable.filter := str;
    adotable.filted := true
      

  2.   

    好像不行吧?应该是like吧!
      

  3.   

    我用以下语句
       s:=  'qybh like '+''''+'%3%'+'''';
       或
       s:=  'qybh = '+''''+'%3%'+'''';
       
       ADOTable1.Filter:=s;
    执行完以后,在dbgrid中一点反映也没有,光标还指在第一行。
    请问,如果我有10条数据,filter后,如果找到1条,是把光标移到他那里‘
    还是结果集就省下一条数据?
      

  4.   

    用LOCATE可以的,能找到相似的记录
      

  5.   

    最好不要用Locate
    数据量大的话,会很慢
      

  6.   

    呵呵  能 我在以前试验过
     有SQL的Like多好啊!
      

  7.   

    用LOCATE可以带模糊查询,那要LOCATE精确查询又怎么办?
      

  8.   

    if locate('姓名',vararrayof([edit1.text]),[locaseinsensitive]) then
            begin
            showmessage('確有此人');
            end
            else
            showmessage('查無此人');
      

  9.   

    function Locate(const KeyFields: String; const KeyValues: Variant; Options: TLocateOptions): Boolean;其中
    oCaseInsensitive Key fields and key values are matched without regard to case.loPartialKey Key values can include only part of the matching key field value; for example, 'HAM' would match both 'HAMM' and 'HAMMER.'
      

  10.   

    var 
      strtmp:string;
    begin
      strtmp:=edit1.text;
      with Datasource1.dataset do
      if lookup('fieldname',vararrayof([strtmo]),'fieldname')<>null
        then 
         locate('fieldname',vararrayof([strtmo]),[locaseinsensitive])
        else
          showmessage('not find!');
    end