ADOQueryTmp.Locate('itembm',copy(m,1,4), [loPartialKey])  解释一下什么意思

解决方案 »

  1.   

    在当前数据集里面查找 字段为“itembm” 字段值中包括copy(m,1,4)的记录 !
      

  2.   

    通过adoquery的locate方法在一个数据集中找到指定的行并定位到当前行
    下面是delphi帮助文档中关于locate方法的全英文解释。其实楼主可以在delphi代码中将光标定位到adoquery.locate中的locate处,按F1键,选择相应的VCL帮助项就可查看delphi的帮助了。Delphi syntax:function Locate(const KeyFields: String; const KeyValues: Variant; Options: TLocateOptions): Boolean; override;C++ syntax:virtual bool __fastcall Locate(const AnsiString KeyFields, const System::Variant &KeyValues, TLocateOptions Options);DescriptionCall Locate to search a dataset for a specific row and make it the current row.KeyFields is a string containing a semicolon-delimited list of field names on which to search.KeyValues is a variant that specifies the values to match in the key fields. If KeyFields lists a single field, KeyValues specifies the value for that field on the desired row. To specify multiple search values, pass a variant array as KeyValues, or construct a variant array on the fly using the VarArrayOf routine. For example:with ADOTable1 do
      Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver', 'P', '408-431-1000']), [loPartialKey]);
    TLocateOptions Opts;
    Opts.Clear();
    Opts << loPartialKey;
    Variant locvalues[2];
    locvalues[0] = Variant("Sight Diver");
    locvalues[1] = Variant("P");
    CustTable->Locate("Company;Contact", VarArrayOf(locvalues, 1), Opts);Options is a set that optionally specifies additional search latitude when searching on string fields. If Options contains the loCaseInsensitive setting, then Locate ignores case when matching fields. If Options contains the loPartialKey setting, then Locate allows partial-string matching on strings in KeyValues. If Options is an empty set, or if KeyFields does not include any string fields, Options is ignored.Locate returns true if it finds a matching row, and makes that row the current one. Otherwise Locate returns false.
      

  3.   

    ADOQueryTmp.Locate('itembm',copy(m,1,4), [loPartialKey]) 定位并移动到itembm为m的第一个字符到第四个字符子串的位置,loPartialKey意思是部分匹配也可以