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 Programming » Tutorial: A sample application for M-Business Anywhere

 

Lesson 7: Add synchronization to your application

The following procedure implements synchronization.

 Add a synchronization function to your application
  1. Add the Synchronize function to 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.getMessage() );
        }
    }

    The synchronization parameters are stored in the SyncParms object. For example, the SyncParms.userName property specifies the user name for which MobiLink searches. The SyncParms.sendColumnNames property specifies that the column names are sent to MobiLink so that it can generate upload and download scripts.

    This function uses a TCP/IP synchronization stream and the default network communication options (stream parameters). These default options assume that you are synchronizing from either a Windows Mobile client connected to the computer running the MobiLink server via ActiveSync, or from a 32-bit Windows desktop client running on the same computer as MobiLink. If this is not the case, change the synchronization stream type and set the network communication options to the appropriate values.

    See also:

  2. Add the following function to main.htm:

    function ClickSync()
    {
        Synchronize();
        DisplayRow();
    }
  3. Start the MobiLink server using the tutorial_mlsrv.bat file.

The data in the Customer table should now be downloaded. You should be able to move through the rows in the Customer table of the remote database.

This completes the tutorial. See Listings for main.htm and tutorial.js for complete code samples for main.htm and tutorial.js.