This lesson synchronizes your application with a consolidated database running on your computer.
The following procedures add synchronization code to your application, start the MobiLink server, and run your application to synchronize.
The UltraLite database you created in the previous lessons synchronizes with the UltraLite 11 Sample database. The UltraLite 11 Sample database has a ULCustomer table whose columns include those in the customer table of your local UltraLite database.
This lesson assumes that you are familiar with MobiLink synchronization.
Add synchronization to your application
Add the method below to customer.cpp. This method carries out the following tasks:
bool do_sync( Connection * conn ) { ul_synch_info info; ul_stream_error * se = &info.stream_error; ULEnableTcpipSynchronization( Tutca.GetCA() ); conn->InitSynchInfo( &info ); info.stream = ULSocketStream(); info.version = UL_TEXT( "custdb 11.0" ); info.user_name = UL_TEXT( "50" ); info.download_only = true; if( !conn->Synchronize( &info ) ) { _tprintf( _TEXT("Synchronization error \n" )); _tprintf( _TEXT(" stream_error_code is '%lu'\n"), se->stream_error_code ); _tprintf( _TEXT(" system_error_code is '%ld'\n"), se->system_error_code ); _tprintf( _TEXT(" error_string is '") ); _tprintf( _TEXT("%s"), se->error_string ); _tprintf( _TEXT("'\n") ); return false; } return true; } |
Add the following line to the main method, immediately after the call to the insert method and before the call to the select method:
do_sync(conn); |
Compile your application by running nmake.
Synchronize data
Start the MobiLink server.
From a command prompt, run the following command:
mlsrv11 -c "dsn=SQL Anywhere 11 CustDB" -v+ -zu+ |
The -zu+ option provides automatic addition of users. The -v+ option turns on verbose logging for all messages.
For more information about this option, see MobiLink server options.
Run your application by typing customer at the command prompt.
The MobiLink server window displays status messages indicating the synchronization progress. If synchronization is successful,
the final message displays Synchronization complete
.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |