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

SQL Anywhere 12.0.0 (中文) » UltraLite - M-Business Anywhere 编程 » 了解 UltraLite for M-Business Anywhere 开发

 

M-Business Anywhere 应用程序中的永久名称

在 HTML 中,当控制转移到新页时,旧页的已分配 JavaScript 对象的所有句柄都会丢失。例如,在 main.html 中,您拥有一个 M-Business Anywhere 数据库连接对象:

conn = dbMgr.openConnection("...");

如果您在 main.html 中单击一个链接并且它将您带到一个不同的页(例如:insert.html),那么,您在 insert.html 中找不到名为 "conn" 的对象。要取回连接对象,您可能需要再次调用 dbMgr.openConnection("...")。但是,您不必执行此操作,因为连接对象仍在内存中,您仅仅丢失了它的 JavaScript 句柄。

这就是为什么在对 DataManager、Connection、ULTable、PreparedStatement 或 ResultSet 的所有 M-Business Anywhere API 调用中都有一个 persistName 参数的原因。例如,当 M-Business Anywhere 运行库接收到来自 JavaScript 对 UltraLite 连接对象的调用时,M-Business Anywhere 首先检查具有相同 persistName 的连接对象是否存在于内存中。如果运行时能够找到匹配的对象,它将返回该连接对象。否则,M-Business Anywhere 执行常规过程创建一个新的 UltraLite 数据库连接并返回它。

 使用永久名称
 正确使用永久名称