Adding synchronization capabilities to your application

To test the synchronization objects generated by the MobiLink Synchronization for ASA wizard or the UltraLite Synchronization wizard, complete the following steps:

  1. Run the wizard.

  2. Call synchronization objects from your application.

  3. Deploy the application and database files.

  4. Start the MobiLink server.

  5. Run the application.

Run the wizard

For remote SQL Anywhere databases The wizard prompts you for a database profile, a file DSN, and a publication. You can use the SalesDB values if you set up the databases and profile. Continue through the wizard, selecting default values, and click Finish to generate the synchronization objects.

For remote UltraLite databases The wizard prompts you for a publication and a script version. For testing purposes, you can leave the script version blank and, for UltraLite 9, select the Send Column Names check box. In UltraLite 10, the column names are used by the MobiLink server for direct row handling. You need to set this option only when using the row handling API to refer to columns by name rather than by index.

Continue through the wizard, selecting default values, and click Finish to generate the synchronization objects.

For all remote databases For information on the objects generated by the wizards for remote SQL Anywhere or UltraLite databases, see the chapter on managing databases in the User’s Guide. For help in wizard screens, place the mouse pointer in any wizard field and press F1.

Call synchronization objects from your application

In a Menu object for your application, add two submenu items to the File menu, called Synchronize and Sync Options. Alternatively, you can use these names to label two buttons on an application window.

For remote SQL Anywhere databases Add the following code to the Clicked event of the Synchronize menu item or button (appname is the name of your application):

gf_appname_sync("tutorial", "")

Add the following code to the Clicked event of the Sync Options menu item or button:

gf_appname_options_sync()

For remote UltraLite databases Add the following code to the Clicked event of the Synchronize menu item or button (appname is the name of your application):

gf_appname_ulsync("dba", "sql", sqlca)

Add the following code to the Clicked event of the Sync Options menu item or button:

gf_appname_options_ulsync(sqlca)

Deploy the application and database files

Use the Project painter to deploy the application to the Pocket PC or emulator. For remote SQL Anywhere databases, you need to copy the file DSN for the remote database to the root directory of the device or emulator, and copy the remote database and its transaction log file to the directory on the device or emulator specified in the DSN.For more information about copying files to devices or emulators, see the Installation Guide.

Start the MobiLink server

Select MobiLink Synchronization Server from the Utilities folder in the Database painter. In the dialog box, select the Automatic Addition of Users check box. This ensures that the MobiLink names created in remote databases are registered for synchronization. Click OK to start the server.

NoteTesting purposes only Typically, you would not select the Automatic Addition of Users option for applications that you create for production.

Run the application

Run the application on the device or emulator and select the File>Synchronize and File>Sync Options menu items or buttons to test their operation.