Understanding UltraLite.NET Development
Accessing and manipulating data with the Table API
UltraLite has several modes of operation for working with data. Two of these modes, the find and lookup modes, are used for searching. The Table object has methods corresponding to these modes for locating particular rows in a table.
NoteThe columns searched using Find and Lookup methods must be in the index used to open the table. |
Find methods move to the first row that exactly matches specified search values, under the sort order specified when the Table object was opened. If the search values cannot be found, the application is positioned before the first or after the last row.
Lookup methods move to the first row that matches or is greater than a specified search value, under the sort order specified when the Table object was opened.
To search for a row
Enter find or lookup mode.
The mode is entered by calling a method on the table object. For example, the following code enters find mode.
t.FindBegin();
Set the search values.
You do this by setting values in the current row. Setting these values affects the buffer holding the current row only, not the database. For example, the following code sets the value in the buffer to Kaminski.
// iAnywhere.Data.UltraLite namespace int lname = t.GetOrdinal( "lname" ); t.SetString( lname, "Kaminski" );
// iAnywhere.UltraLite namespace short lname = t.Schema.GetColumnID( "lname" ); t.SetString( lname, "Kaminski" );
Search for the row.
Use the appropriate method to carry out the search. For example, the following instruction looks for the first row that exactly matches the specified value in the current index.
For multi-column indexes, a value for the first column is always used, but you can omit the other columns.
tCustomer.FindFirst();
Search for the next instance of the row.
Use the appropriate method to carry out the search. For a find operation, FindNext() locates the next instance of the parameters in the index. For a lookup, MoveNext() locates the next instance.
For more information, see ULTable class (iAnywhere.Data.UltraLite namespace) or Table class (iAnywhere.UltraLite namespace).
SQL Anywhere Studio 9.0.2
Copyright © 1989–2004 Sybase, Inc. Portions copyright © 2001–2004 iAnywhere Solutions, Inc. All rights reserved.