Contents Index Databases on the Palm Computing Platform Closing connections and tables

UltraLite for MobileVB User's Guide
  Understanding UltraLite for MobileVB Development
    Maintaining database state on Palm OS

Using the persistent name


When a request is made to open a table, the user can pass in a persistent name. UltraLite looks up the persistent name in the state PDB to see if there is a table associated with it. If so, the table is opened and positioned to the proper row. If not, the table is opened and positioned before the first row.

When an application terminates, it may or may not explicitly close the UltraLite connection and all open tables. If it does not, then UltraLite records the current row of each open table that was supplied with a persistent name. Tables without a persistent name are closed.

Suppose the Connection object is of type ULConnection and a table called ULCustomer exists in the database.

Dim table As ULTable
Set table = Connection.GetTable( "ULCustomer" )
table.Open "", "customer"

The second line of code gets the table object representing the ULCustomer table. The table has not been opened for reading or writing yet.

In the Open call (the third line of code), the first parameter is the empty string, which indicates that the data will be ordered by the primary key. The second parameter is the persistent name being assigned to the table. If the application terminates while this table is still open, the state PDB will associate customer with the ULCustomer table and save the current position.

Persistent name notes 
Why a separate persistent name is needed 

It is possible with UltraLite to have the same table open multiple times and at the same time in your application. In this case, the table name is not unique enough to store in the state PDB. In an application that does this, the code would look something like the following:

Set table1 = Connection.GetTable( "ULCustomer" )
table1.Open "", "customer1"
// operations here
Set table2 = Connection.GetTable( "ULCustomer" )
table2.Open "", "customer2"

Contents Index Databases on the Palm Computing Platform Closing connections and tables