FireDAC.Comp.DataSet.TFDDataSet.SetKey

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure SetKey;

C++

void __fastcall SetKey();

Properties

Type Visibility Source Unit Parent
procedure
function
public
FireDAC.Comp.DataSet.pas
FireDAC.Comp.DataSet.hpp
FireDAC.Comp.DataSet TFDDataSet

Description

Starts the entering key values mode.

Use SetKey to put the dataset into the dsSetKey state, clear the current content of the search key buffer, and enable to enter key field values. 

Use EditKey to modify existing key field values without initially erasing them.

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');

See Also