delphi xe 之路(23)clientdataset的locate函数

来源:互联网 发布:本地服务器搭建软件 编辑:程序博客网 时间:2024/05/22 03:15
 locate主要用于查找数据,但是它的查找速度没有finding和going定位快。下面我举一个例子。
procedure TForm1.LocateBtnClick(Sender: 
TObject);
begin
Start;
if ClientDataSet1.Locate('Field1,Field2..',VarArrayOf['value1,value2..'], []) then
begin
Done;
StatusBar1.Panels[3].Text :=
'Match located at record ' +
IntToStr(ClientDataSet1.RecNo);
end
else
begin
Done;
StatusBar1.Panels[3].Text := 'No match located';
end;
end;

 函数原型为clientdataset 1.locate(const KeyFields: String; const KeyValues: Variant;Options: TLocateOptions): Boolean;
参数 :KeyFields 是查询的字段名;
KeyValues 是查询的条件值;
Options 是查询标准 ,分为 
[ loCaseInsensitive] 不分大小写
[ loPartialKey] 部分字符
[ ] 一模一样

0 0
原创粉丝点击