procedure TSearchDemo.SearchExactClick(Sender: TObject); begin ClientDataSet1.SetKey; ClientDataSet1.Fields[0].AsString := Edit1.Text; if not ClientDataSet1.GotoKey then ShowMessage('Record not found'); end;
void __fastcall TSearchDemo::SearchExactClick(TObject *Sender) { ClientDataSet1->SetKey(); ClientDataSet1->Fields->Fields[0]->AsString = Edit1->Text; if (!ClientDataSet1->GotoKey()) ShowMessage("Record not found"); }
GotoNearest is similar. It searches for the nearest match to a partial field value. It can be used only for string fields. For example,
Table1.SetKey; Table1.Fields[0].AsString := 'Sm'; Table1.GotoNearest;
Table1->SetKey(); Table1->Fields->Fields[0]->AsString = "Sm"; Table1->GotoNearest();
If a record exists with "Sm" as the first two characters of the first indexed field's value, the cursor is positioned on that record. Otherwise, the position of the cursor does not change and GotoNearest returns False.
Executing a Search with Find Methods
Specifying the Current Record After a Successful Search
Reapeating or Extending a Search
SetKey
SetKey
GotoKey
GotoKey
GotoNearest
GotoNearest
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|