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.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|