鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 编程语言开发 > delphi > >

Searching for Data

来源:互联网 作者:佚名 时间:2012-12-23 12:44
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 ShowMessag

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

posted on

Copyright ©2012 许小东 Powered by: 博客园 模板提供:沪江博客

网站空间虚拟主机香港服务器
网友评论
<