Understanding UltraLite.NET Development
Accessing and manipulating data with the Table API
UltraLite.NET provides you with a number of methods to navigate a table in order to perform a wide range of navigation tasks.
The table object provides you with the following methods to navigate a table.
MoveAfterLast() moves to a position after the last row.
MoveBeforeFirst() moves to a position before the first row.
MoveFirst() moves to the first row.
MoveLast() moves to the last row.
MoveNext() moves to the next row.
MovePrevious() moves to the previous row.
MoveRelative( offset ) moves a certain number of rows relative to the current row, as specified by the offset. Positive offset values move forward in the table, relative to the current position of the cursor in the table, and negative offset values move backward in the table. An offset value of zero does not move the cursor, but allows you to repopulate the row buffer.
The following code opens the MyTable table and displays the value of the MyColumn column for each row.
// iAnywhere.Data.UltraLite namespace
ULTable t = conn.ExecuteTable( "MyTable" );
int colID = t.GetOrdinal( "MyColumn" );
while ( t.MoveNext() ){
System.Console.WriteLine( t.GetString( colID ) );
}// iAnywhere.UltraLite namespace
Table t = conn.GetTable( "MyTable" );
short colID = t.Schema.GetColumnID( "MyColumn" );
t.Open();
t.MoveBeforeFirst();
while ( t.MoveNext() ){
System.Console.WriteLine( t.GetString( colID ) );
}You expose the rows of the table to the application when you open the table object. By default, the rows are ordered by primary key value, but you can specify an index when opening a table to access the rows in a particular order.
The following code moves to the first row of the MyTable table as ordered by the ix_col index.
// iAnywhere.Data.UltraLite namespace ULTable t = conn.ExecuteTable( "MyTable", "ix_col" ); t.MoveFirst(); // iAnywhere.UltraLite namespace Table t = conn.GetTable( "MyTable" ); t.Open( "ix_col" ); t.MoveFirst();
For more information, see ULTable class and ULTableSchema class and (iAnywhere.Data.UltraLite namespace) or Table class and TableSchema 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.