Contents Index Lesson 5: Build and run your application Restore the sample database pdf/preface.pdf

UltraLite User's Guide
  Tutorial: Build an Application Using the C++ API

Lesson 6: Add synchronization to your application


UltraLite applications exchange data with a consolidated database. In this lesson, you add synchronization to the simple application you created in the previous section. In addition, you change the output to verify that synchronization has taken place.

Adding synchronization actually simplifies the code. Your initial version of main.cpp has the following lines, that inserts some data into your UltraLite database.

productTable.SetProd_id( 1 );
productTable.SetPrice( 400 );
productTable.SetProd_name( "4x8 Drywall x100" );
productTable.Insert();

productTable.SetProd_id( 2 );
productTable.SetPrice( 3000 );
productTable.SetProd_name( "8' 2x4 Studs x1000" );
productTable.Insert();

This code is included to provide an initial set of data for your application. In a production application, you would usually not insert an initial copy of your data from source code, but would carry out a synchronization.

To add synchronization to your application

  1. Add a synchronization information structure to your code.

  2. Replace the explicit inserts with a synchronization call.

  3. Compile and link your application.

  4. Start the MobiLink server running against the sample database.

    From a command prompt in your APITutorial directory, enter the following command:

    start dbmlsrv9 -c "dsn=UltraLite 9.0 Sample"
  5. Run your application.

    From the Build menu, choose Execute APITutorial.exe.

    The application connects, synchronizes to receive data, and writes out information to the command prompt window. The output is as follows:

    The ULData object is open
    Price: 400
    Price: 3000
    Price: 40
    Price: 75
    Price: 100
    Price: 400
    Price: 3000
    Price: 75
    Price: 40
    Price: 100

In this lesson, you have added synchronization to a simple UltraLite application.


Contents Index Lesson 5: Build and run your application Restore the sample database pdf/preface.pdf