用Locate可以实现sql的like '%*%'查找吗?
locate('字段名',变量,[])模糊查找好想是从第一位必须完全匹配

解决方案 »

  1.   

    with ADOTable1 do
      Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver', 'P', '408-431-1000']), [loPartialKey]);

    注意最后一个参数设置胃lopartialkey即可,可以参考DELPHI自带的帮助,
    function Locate(const KeyFields: String; const KeyValues: Variant; Options: TLocateOptions): Boolean; override;type
      TLocateOption = (loCaseInsensitive, loPartialKey);
      TLocateOptions = set of TLocateOption;C++ syntax:enum TLocateOption { loCaseInsensitive, loPartialKey };typedef Set<TLocateOption, loCaseInsensitive, loPartialKey>  TLocateOptions;DescriptionTLocateOptions is the type of the Options parameter to a dataset抯 Locate method. The following table lists the possible values:Value DescriptionloCaseInsensitive 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.'