UltraLite for MobileVB User's Guide
Understanding UltraLite for MobileVB Development
Maintaining database state on Palm OS
The PersistentName example program is a relatively simple program that shows how to use maintained state information. It is available at http://www.sybase.com/detail?id=1022734. Here are some highlights from the sample:
CustomerTable.Open AddRow "John", "Doe", "Atlanta" AddRow "Mary", "Smith", "Toronto" AddRow "Jane", "Anderson", "New York" AddRow "Margaret", "Billington", "Vancouver" AddRow "Fred", "Jones", "London" AddRow "Jack", "Frost", "Dublin" AddRow "David", "Reiser", "Berlin" AddRow "Kathy", "Stevens", "Waterloo" AddRow "Rebecca", "Gable", "Paris" AddRow "George", "Jenkins", "Madrid" CustomerTable.Close
This code adds ten rows to the ULCustomer table. It calls Open on the table, but in this case a persistent name is not supplied because we are not interested in maintaining the position in the table. Since the code only inserts data, the position in the table is not relevant.
The following line opens the ULCustomer table, ordering rows by the primary key and assigning a persistent name of customer.
CustomerTable.Open "" , "customer"
If the application has been run before, then a lookup is done in the state database for customer. Otherwise, customer is associated with this table.
The customer table is left open for the duration of the running application. If the user switches to another application, UltraLite records the position in the table where the user left off.When the application is started again, the table is opened and UltraLite determines that position information is known for a table with the persistent name customer, so it positions the user back on that row.
When the user clicks the End button, the customer table and the connection are closed before the application disappears. This has the effect of discarding any state information for the customer table, so when the application is restarted, the user is positioned on the first row.