Show: Delphi C++
Display Preferences

Datasnap.DBClient.TCustomClientDataSet.Locate

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Locate(const KeyFields: string; const KeyValues: Variant;  Options: TLocateOptions): Boolean; override;

C++

virtual bool __fastcall Locate(const System::UnicodeString KeyFields, const System::Variant &KeyValues, Data::Db::TLocateOptions Options);

Properties

Type Visibility Source Unit Parent
function public
Datasnap.DBClient.pas
Datasnap.DBClient.hpp
Datasnap.DBClient TCustomClientDataSet

Description

Searches the dataset for a specified record and makes that record current.

Call Locate to search a dataset for a specific record and position the cursor on it. KeyFields is a string containing a semicolon-delimited list of field names on which to search.

KeyValues is a Variant containing the values to match in the key fields. If KeyFields lists a single field, KeyValues represents the search value for that field. If KeyFields lists multiple fields, pass a Variant array as the KeyValues parameter. In Delphi, you can construct a variant array on the fly using the VarArrayOf routine. For example:

with CustTable do
Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver', 'P', '831-431-1000']), [loPartialKey]);



TLocateOptions Opts;
Opts.Clear();
Opts << loPartialKey;
Variant locvalues[3];
locvalues[0] = Variant("Sight Diver");
locvalues[1] = Variant("P");
locvalues[2] = Variant("831-431-1000");



CustTable->Locate("Company;Contact;Phone", VarArrayOf(locvalues, 2), Opts);


Options is a set that optionally specifies additional search latitude when searching on string fields. If Options contains the loCaseInsensitive setting, then Locate ignores case when matching fields. If Options contains the loPartialKey setting, then the KeyValues parameter can specify incomplete strings for field values. (For example, in the previous statement, the Contact field would match any record where Contact begins with 'P'). If Options is an empty set, or if the KeyFields are not string fields, Options is ignored.

Locate returns True if it finds a matching record, and makes that record the current one; otherwise, Locate returns False.

See Also

Personal tools
In Other Languages
Previous Versions
Assistance