Contents Index Searching for rows with find and lookup Transaction processing in UltraLite

UltraLite.NET User's Guide
  Understanding UltraLite Development
    Accessing and manipulating data with the Table API

Inserting updating, and deleting rows


To update a row in a table, use the following sequence of instructions:

  1. Move to the row you wish to update.

    You can move to a row by scrolling through the table or by searching, using find and lookup methods.

  2. Enter update mode.

    For example, the following instruction enters update mode on t:

    t.BeginUpdate();
  3. Set the new values for the row to be updated. For example:

    t.SetInt( id , 3);
  4. Execute the Update.

    t.Update();

After the update operation the current row is the row that was just updated. If you changed the value of a column in the index specified when the Table object was opened, the current row is undefined.

By default, UltraLite.NET operates in autocommit mode, so that the update is immediately applied to the row in permanent storage. If you have disabled autocommit mode, the update is not applied until you execute a commit operation. For more information, see Transaction processing in UltraLite.

Caution    You can not update the primary key of a row: delete the row and add a new row instead.

Inserting rows 

The steps to insert a row are very similar to those for updating rows, except that there is no need to locate any particular row in the table before carrying out the insert operation. The order of row insertion into the table has no significance.

For example, the following sequence of instructions inserts a new row:

t.InsertBegin();
t.SetInt( id, 3 );
t.SetString( lname, "Carlo" );
t.Insert();

If you do not set a value for one of the columns, and that column has a default, the default value is used. If the column has no default, the following entries are added:

As for update operations, an insert is applied to the database in permanent storage itself when a commit is carried out. In AutoCommit mode, a commit is carried out as part of the insert method.

Deleting rows 

The steps to delete a row are simpler than to insert or update rows. There is no delete mode corresponding to the insert or update modes. The steps are as follows:

  1. Move to the row you wish to delete.

  2. Execute the Table.Delete() method.


Contents Index Searching for rows with find and lookup Transaction processing in UltraLite