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

SQL Anywhere 12.0.1 » UltraLite - M-Business Anywhere 编程(不建议使用) » 教程:构建 M-Business Anywhere 应用程序

 

第 7 课:向应用程序添加同步

以下过程实现同步。

 ♦ 将同步函数添加到应用程序
  1. Synchronize 函数添加到 tutorial.js



    function Synchronize()
    {
        var sync_parms; 
        
        sync_parms = Connection.syncParms;     
        sync_parms.setUserName( "tutorial" );    
        sync_parms.setPassword( "tutorial" );    
        sync_parms.setVersion( "tutorial" );    
        sync_parms.setStream( sync_parms.STREAM_TYPE_TCPIP );
        try {
     Connection.synchronize();
        } catch( ex ) {
         alert( "Error: cannot synchronize: " + ex.Message() );
        }
    }

    同步参数存储在 SyncParms 对象中。例如,SyncParms.userName 属性指定 MobiLink 搜索的用户名。SyncParms.sendColumnNames 属性指定发送到 MobiLink 用于生成上载和下载脚本的列名。

    此函数使用 TCP/IP 同步流和缺省网络通信选项(流参数)。这些缺省选项假定您的同步方式为以下两种中的一种:即通过 ActiveSync 从连接到运行 MobiLink 服务器的计算机的 Windows Mobile 客户端同步,或者从 MobiLink 所在计算机上运行的 32 位 Windows 桌面操作系统客户端同步。如果不是这种情况,更改同步流类型,并将网络通信选项设置为相应的值。

    另请参见:

  2. 将以下函数添加到 main.htm

    function ClickSync()
    {
        Synchronize();
        DisplayRow();
    }
  3. 使用 tutorial_mlsrv.bat 文件启动 MobiLink 服务器。

现在应下载 Customer 表中的数据。您应该能够在远程数据库的 Customer 表中的各行之间移动。

至此,本教程结束。有关 main.htmtutorial.js 的完整代码示例,请参见main.htm 和 tutorial.js 的列表