zoukankan      html  css  js  c++  java
  • ADO_Locate(数据查找与定位)

    在Delphi中,Locate和Lookup封装了原生ADO的Find查找方法。提供以下函数形式使用

     1 function TCustomADODataSet.Locate(const KeyFields: string;
     2   const KeyValues: Variant; Options: TLocateOptions): Boolean;
     3 begin
     4   DoBeforeScroll;
     5   Result := LocateRecord(KeyFields, KeyValues, Options, True);
     6   if Result then
     7   begin
     8     Resync([rmExact, rmCenter]);
     9     DoAfterScroll;
    10   end;
    11 end;
    12 
    13 function TCustomADODataSet.Lookup(const KeyFields: stringconst KeyValues: Variant;
    14   const ResultFields: string): Variant;
    15 begin
    16   Result := Null;
    17   if LocateRecord(KeyFields, KeyValues, [], False) then
    18   begin
    19     SetTempState(dsCalcFields);
    20     try
    21       CalculateFields(TempBuffer);
    22       Result := FieldValues[ResultFields];
    23     finally
    24       RestoreState(dsBrowse);
    25     end;
    26   end;
    27 end;

    使用时 loCaseInsensitive代表区分大小写,loPartialKe代表部分匹配。

    当多个字段时用“;”隔开字段名,字段值是变体数组形式,可以用VarArrayof()生成。

    例如:ds1.Locate('name', 'k1727', [loCaseInsensitive, loPartialKe]);

  • 相关阅读:
    各种数据库查询表及表信息的SQL
    多维表头的DataGridView
    SQLite入门笔记
    配置WCF的心得
    JS键盘的键码
    ASP.NET的URL过滤
    利用反射查看类成员
    一个简单的MVC示例
    一个日志类 LogUtil
    一个IniHelper
  • 原文地址:https://www.cnblogs.com/k1727/p/2335595.html
Copyright © 2011-2022 走看看