Delphi通过查找字符定位TADOQuery数据的位置

来源:互联网 发布:金融数据分析师怎么样 编辑:程序博客网 时间:2024/05/16 06:28

     通过TADOQuery的方法Locate,输入字符,查找到定位到对应的数据位置,优点快速定位,缺点是只匹配查找到的和第一个位置,无法连续定位下一个!

//定位
qrymembertype.Locate('Cname', Cname, [loCaseInsensitive]);

'Cname'列名
Cname 所匹配的值
loCaseInsensitive, loPartialKey] 不区分大小写,部分匹配
[loCaseInsensitive] 不区分大小写
[loPartialKey] 部分匹配
[] 完全相同

同进匹配多个属性:
if edtsearch.Text <> '' then
  begin
    if not qry1.Locate('Cid', edtsearch.Text, [loPartialKey]) then
    begin
      if not qry1.Locate('cname', edtsearch.Text, [loPartialKey]) then
      begin
        qry1.Locate('cago', edtsearch.Text, [loPartialKey]);
      end;
    end;
  end;

0 0
原创粉丝点击