Contents Index Searching for rows with Find and Lookup Transaction processing in UltraLite

UltraLite for MobileVB User's Guide
  Understanding UltraLite for MobileVB Development
    Accessing data using the table-based 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 TCustomer:

    TCustomer.UpdateBegin
  3. Set the new values for the row to be updated. For example:

    TCustomer.Column( "LName" ).StringValue = "Smith"
  4. Execute the Update.

    TCustomer.Update

    The update is not carried out until the Update method is called.

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 ULTable object was opened, the current row is undefined. For more information, see Update method

By default, UltraLite 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 made permanent until you execute a Commit operation. For more information, see Transaction processing in UltraLite.

Caution    Updating primary key values can interfere with synchronization. Do 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 rows in the table has no significance.

Note: The location of the cursor's current row is not defined after an insert. So you should not rely on the current row position after an insert.

The following sequence of instructions inserts a new row:

TCustomer.InsertBegin
TCustomer.Column( "Id" ).IntegerValue = 3
TCustomer.Column( "LName" ).StringValue = "Carlo"
TCustomer.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, after calling Insert it is possible to see the newly inserted row, but an Insert is applied to the database in permanent storage itself only 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 ULTable.Delete method.


Contents Index Searching for rows with Find and Lookup Transaction processing in UltraLite