FireDAC.Comp.DataSet.TFDDataSet.GotoKey
Delphi
function GotoKey: Boolean;
C++
bool __fastcall GotoKey();
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | FireDAC.Comp.DataSet.pas FireDAC.Comp.DataSet.hpp |
FireDAC.Comp.DataSet | TFDDataSet |
Description
Searches for a record, using values in the key buffer.
Use GotoKey to search for a record using values assigned to the indexed fields after a previous call of SetKey/EditKey.
Before the call, the dataset must be in dsSetKey
state. If GotoKey finds a record, it makes it the current record in the dataset and returns True. Otherwise, the current position remains unchanged and GotoKey returns False.
Example
FDQuery1.IndexFieldNames := 'CUSTOMER_ID;ORDER_DATE';
FDQuery1.SetKey;
FDQuery1.FieldByName('CUSTOMER_ID').AsInteger := 100;
FDQuery1.FieldByName('ORDER_DATE').AsDateTime := EncodeDate(2008, 5, 1);
if not FDQuery1.GotoKey then
ShowMesage('Order is not found');