Collection Contents 上一页 下一页 PDF

UltraLite for MobileVB 用户指南

了解 UltraLite for MobileVB 开发

在 UltraLite Palm 应用程序中维护状态

示例:使用永久名称来维护状态信息


PersistentName 示例程序是一个比较简单的程序,它说明了如何使用维护的状态信息。其下载网址为 [external link] http://www.sybase.com/detail?id=1022734。下面是该示例的一些要点:

'MobileVB
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

此代码给 ULCustomer 表添加了十行。它在表上调用 Open,但在此情况下,不提供永久名称,因为我们对于维护表中的位置不感兴趣。由于该代码只插入数据,所以表中的位置是不相关的。

下面的行打开 ULCustomer 表,按主键给行排序并指派 [customer] 作为永久名称。

CustomerTable.Open "" , "customer"

如果以前运行了该应用程序,则在状态数据库中为 [customer] 完成了查询。否则,[customer] 会与此表关联。

customer 表会在应用程序运行期间保持打开状态。如果用户切换到另一应用程序,UltraLite 会记录表中用户离开时的位置。当应用程序再次启动时,该表会打开,并且 UltraLite 会确定该位置信息对于永久名称为 [customer] 的表是已知的,所以它会将用户定位回该行。

当用户单击 [End] 按钮时,customer 表和连接会关闭,然后应用程序消失。这样就相当于放弃 customer 表的任何状态信息,所以,当该应用程序重新启动时,该用户会被定位到第一行。


Collection Contents 上一页 下一页 PDF