Searching for Data

Locate

    AdoTable1.Locate('Name','Zoom',[]);

    var ffield, fvalue: string;

           opts : TLocateOptions;

    ffield := 'Name';

    fvalue := 'zoom';

    opts := [loCaseInsensitive]; 

    if not AdoTable1.Locate(ffield, fvalue, opts) then 

       ShowMessage(fvalue + ' not found in ' + ffield);

 

Lookup

Lookup does not move the cursor to the matching row, it only returns values from it.

var LookupRes: Variant;

LookupRes := ADOTable1.Lookup ('Name', 'Zoom', 'Author; Description');

 if not VarIsNull(LookupRes) then

ShowMessage(VarToStr(LookupRes[0])) //author name

Seek

The ADO datasets Seek method uses an index when performing a search.

You cannot use the Seek method on TADOQuery component.

  function Seek(const KeyValues: Variant; SeekOption: TSeekOption = soFirstEQ): Boolean;

  TSeekOption:   soFirstEQ,soLastEQ,soAfterEQ,soAfter,soBeforeEQ,soBefore

 

var strIndex: string;

strIndex := ComboBox1.Text; //from the code above

 

if ADOTable1.Supports(coSeek) the begin

  with ADOTable1 do begin

Close;

IndexName := strIndex;

CursorLocation := clUseServer;

Open;

Seek (Edit1.Text, soFirstEQ);

 end;

 if ADOTable1.EOF then

ShowMessage ('Record value NOT found');

 end

转载于:https://www.cnblogs.com/xxd0825/archive/2012/12/13/2816987.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值