Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » UltraLite - AppForge Programming » Understanding UltraLite Development with AppForge » Maintaining state in UltraLite Palm applications

Maintaining state in UltraLite Palm applications Next Page

Understanding how state is maintained


For each table whose state is being preserved, UltraLite stores a name for the table as well as enough information to restore the state of the table. The name associated with the table may be, but is not required to be, the name of the table. It is called the persistent name.

UltraLite applications can open more than one instance of the same table at the same time. In this case, the table name is not unique. For example, the following code (using MobileVB) opens the same table twice:

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

When opening a table, an application can optionally provide a persistent name as a parameter. If the state of the persistent name has been saved, 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 open tables and close the connection. If it does not close an open table, 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.

'MobileVB using VB6
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 is 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 associates customer with the ULCustomer table and save the current position.

Persistent name notes