Create a MobiLink connection

Note

Now you generate a MobiLink connection for the remote application using the MobiLink Synchronization wizard.

  1. Select File>New.

    In the Database tab, select MobiLink Synchronization for ASA.

    Click OK.

    Shown is the Database tab of the New dialog box. The Mobil Link Synchronization for A S A wizard icon is selected.
  2. Read the first overview screen and click Next.

    Read the second screen to learn about what the wizard provides.

    Click Next again.

  3. Click Next to accept salesdb_tutorial.pkl as the default library for storing the generated MobiLink objects.

  4. Select SalesDB_remote from the drop-down menu.

    Click Test Connection.

    Shown is the Desktop Deployment Connection page of the MobiLink Synchronization wizard. The database profile selected is for the Sales D B underscore remote database.

    A Connection successful message should display in the lower-left corner of the wizard page. If it does not, verify that the DSN is correctly configured in PocketBuilder and the ODBC Administrator. The ODBC Administrator is located in the Objects view of the Database painter in the ODB ODBC utilities.

  5. Click Next.

    Choose Browse and then select SalesDB_remote_10.DSN in the \Tutorial\SalesDB directory.

    Shown is the Remote D B Connection from Windows C E page of the MobiLink Synchronization wizard. The O D B C data source file for the connection to the database from the handheld device is set to the Sales D B underscore Remote D S N file.
  6. Click Next to display the wizard page showing publications in the remote database.

    Select the salesapi publication and click Next.

    Shown is the  MobiLink Client Publication page of the MobiLink Synchronization wizard. It lists the publications in the Sales D B underscore remote database. For this database, there is only one publication. The name of thiis publication, sales a p i, is selected for synchronization.
  7. Click Next to accept the default names for the generated MobiLink objects.

    The default names are nvo_salesdb_tutorial_sync for the nonvisual object that will control the MobiLink synchronization client, and gf_salesdb_tutorial_sync for a global function that instantiates the nonvisual object and makes the call to launch a synchronization request.

    After you click Next, the MobiLink Client Display Options page of the wizard displays.

  8. In the Mobilink Client Display Options page, click Next to accept the default option.

    The default display option causes the wizard to generate a synchronization status window named w_salesdb_tutorial_sync.

    After you click Next, the Optional Runtime Configuration Objects wizard page displays. On this page, you specify names of wizard-generated objects that allow users to change synchronization settings at runtime. You can also intruct the wizard not to generate these objects. However, for this tutorial, you leave the default selections.

  9. In the Optional Runtime Configuration Objects page, click Next.

    Shown is the Optional Runtime Configuration Objects page of the MobiLink Synchronization wizard. The optional objects are selected for generation. They include a configure function, an options window, and a structure for parameters that the application user can update at runtime.

    You accept the default selection and instruct the wizard to generate synchronization objects that allow the end user to make runtime changes. The Override Registry Settings wizard page displays.

    NoteIf this were a production environment In this lesson, you give the user significant control of the synchronization parameters. In a production environment however, giving the user a high degree of control over the synchronization parameters is usually not good practice.

  10. In the Override Registry Settings wizard page, keep all the default values and then click Next.

    The MobiLink wizard stores synchronization information for each MobiLink user in the Windows registry on the device and on the desktop. The Override Registry Settings wizard page lets you specify how PocketBuilder adds or modifies registry settings when redeploying and configuring end-user applications.

    After you click Next, the MobiLink Client Logging Options page displays.

  11. Check the Show all except -vc and -vp (-v+) check box.

    Shown is the MobiLink Client Logging Options page of the MobiLink Synchronization wizard. The check box for logging everything except the connect string and MobiLink password is selected. This check box selection corresponds to the dash v plus MobiLink logging option.

    This wizard page determines the amount and type of information shown in the MobiLink status window during synchronization.

    NoteImproving performance for deployed applications The Show all except -vc and -vp (-v+) option can result in the display of many status messages that affect the synchronization speed. To improve performance in a deployed application, show fewer messages.

  12. Click Next.

    The MobiLink Client Additional Options page displays. It allows you to include additional MobiLink command line options or extended options and assign the MobiLink host and port. You must also select the MobiLink server version you want to use.

  13. In the Extended Options text box, type the value lt=share.

    Select 10 for the MobiLink server version.

    Table-locking significantly reduces data transfer times, so for your application to function optimally, you set the LockTable (lt) options to share.

    Shown is the MobiLink Client Additional Options page of the MobiLink Synchronization wizard. The Extended Option L T equals Share is set on this page. The MobiLink server version is set to 10.
  14. Click Next.

    The last wizard page contains a summary of your choices, including the default selections. If you need to, you can go back and change any options that are incorrect.

  15. Click Finish to generate the MobiLink synchronization components in your project.

    The MobiLink Synchronization wizard creates the following synchronization objects:

    Synchronization object

    Description

    nvo_salesdb_tutorial_sync

    Nonvisual user object that controls the MobiLink synchronization client.

    gf_salesdb_tutorial_sync

    Global function that creates the user object and initiates synchronization requests.

    s_salesdb_tutorial_sync_parms

    Structure that stores the MobiLink command line parameters. (All the variables accessible from the wizard are MobiLink command line options.)

    gf_salesdb_tutorial_configure_sync

    Global function that handles a user request to change the synchronization options and stores the values in the Windows/Windows CE registry.

    The MobiLink Synchronization wizard also creates two windows:

    Window

    Use

    w_salesdb_tutorial_sync

    Displays the synchronization status information

    w_salesdb_tutorial_sync_options

    Sets synchronization options at runtime

    Now you enable the w_salesdb_tutorial_sync_options Sync Options window in the Menu painter.

  16. Double-click m_salesdb in the System Tree to open the Menu painter.

    In the Menu painter tree view, expand the File menu and double-click the Sync Options… menu item.

  17. Check to be sure that the drop-down lists at the top of the Script view display the clicked( ) event for the m_file.m_syncoptions object.

    If not, select that object and event from the drop-down lists.

  18. Type the following code in script view:

    // Open the Sync Options window
    gf_salesdb_tutorial_configure_sync()
    
    // Fetch data
    f_refresh_orders(-1)
    
    Shown is the Script view for the Clicked event of the sink options menu. The script calls the global configure function that opens the Sink Options window, then it makes a call to the f underscore refresh underscore orders function to fetch data.

    Next, to enable synchronization when the user clicks Synchronize in the File menu, you add a call to the gf_salesdb_tutorial_sync global function.

  19. In the Menu painter tree view, double-click Synchronize.

    Make sure the drop-down menu at the top of the script view displays the clicked() event for the m_file.m_synchronize object.

  20. Type the following code in script view:

    // Start synchronization
    
    IF gf_salesdb_tutorial_sync(string(::g_emp_id),"")<>0 THEN
    
    MessageBox("Error"," MobiLink Synchronization Error.")
    
    END IF
    
    // Fetch data
    
    f_refresh_orders(-1)
    
    Shown is the Script view for the m underscore synchronize menu item. It calls a global function to start the synchronization, then fetches data with a call to the f underscore refresh underscore orders function.
  21. Select File>Save to save the changes.

    Close the Menu painter.