Navigating the rows of a table

UltraLite.NET provides you with a number of methods to navigate a table 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.

Example

The following code opens the MyTable table and displays the value of the MyColumn column for each row.

ULTable t = conn.ExecuteTable( "MyTable" );
int colID = t.GetOrdinal( "MyColumn" );
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.

Example

The following code moves to the first row of the MyTable table as ordered by the ix_col index.

ULTable t = conn.ExecuteTable( "MyTable", "ix_col" );
t.MoveFirst();

See ULTable class and ULTableSchema class.