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] 部分字符
[ ] 一模一样
参数 :KeyFields 是查询的字段名;
KeyValues 是查询的条件值;
Options 是查询标准 ,分为
[ loCaseInsensitive] 不分大小写
[ loPartialKey] 部分字符
[ ] 一模一样