![]() | Products |
| Home » Technical Support » ElevateDB Technical Support » Product Manuals » ElevateDB Version 2 Manual for RAD Studio XE6 (C++ Win64) » Using ElevateDB » Searching and Sorting Tables, Views, and Query Result Sets |
{
MyTable->IndexName="CustomerName";
// do something
}{
MyTable->IndexFieldNames="CustomerName;CustomerNo";
// do something
}{
// Set to the natural order, which in this case
// is the primary key
MyTable->IndexName="";
// Search for customer 100
// With C++Builder, the column values must be passed
// as either a TVarRec (for single values) or an
// ARRAYOFCONST
TVarRec SearchValue=(100);
if (MyTable->FindKey(&SearchValue))
{
// Row was found, now do something
}
else
{
ShowMessage("Row was not found");
}
}{
// Set to the natural order, which in this case
// is the primary key
MyTable->IndexName="";
// Search for customer 100 or nearest
// With C++Builder, the column values must be passed
// as either a TVarRec (for single values) or an
// ARRAYOFCONST
TVarRec SearchValue=(100);
MyTable->FindNearest(&SearchValue);
}{
// Set to the CustomerName index
MyTable->IndexName="CustomerName";
// Search for the customer with the
// name "The Hardware Store"
MyTable->SetKey();
MyTable->ColumnByName("CustomerName")->AsString="The Hardware Store";
// This causes the search to only look at the first column
// in the current index when searching
MyTable->KeyColumnCount=1;
if (MyTable->GotoKey())
{
// Row was found, now do something
}
else
{
ShowMessage("Row was not found");
}
}{
// Set to the CustomerName index
MyTable->IndexName="CustomerName";
// Search for the customer with the
// name "The Hardware Store"
MyTable->SetKey();
MyTable->ColumnByName("CustomerName")->AsString="The Hardware Store";
// This causes the search to only look at the first column
// in the current index when searching
MyTable->KeyColumnCount=1;
MyTable->GotoNearest();
}CREATE INDEX State ON Customer (State)
{
Variant SearchValues[1];
SearchValues[0]=Variant("FL");
// Search for the customer with the
// state "FL"
if (MyTable->Locate("State",VarArrayOf(SearchValues,2),
TLocateOptions() << loCaseInsensitive))
{
// Row was found, now do something
}
else
{
ShowMessage("Row was not found");
}
}CREATE INDEX State ON Customer (State)
{
Variant SearchValues[1];
SearchValues[0]=Variant("FL");
// Search for the customer with the
// state "FL"
if (MyTable->Locate("State",VarArrayOf(SearchValues,2),
TLocateOptions()))
{
// Row was found, now do something
}
else
{
ShowMessage("Row was not found");
}
}{
// Search for the first customer with the
// name "The Hardware Store"
MyTable->Filter="CustomerName="+QuotedStr("The Hardware Store");
// We want the search to be case-insensitive
TFilterOptions FilterOptions;
FilterOptions->Clear();
FilterOptions << foCaseInsensitive;
MyTable->FilterOptions=FilterOptions;
if (MyTable->FindFirst())
{
// Row was found, now search through
// the rest of the matching rows
while (FindNext())
{
// Do something here
}
}
else
{
ShowMessage("Row was not found");
}
}This web page was last updated on Tuesday, September 16, 2025 at 04:56 PM | Privacy Policy © 2026 Elevate Software, Inc. All Rights Reserved Questions or comments ? |

