Creating an instance of MLSync
You do not have to use the MobiLink Synchronization Wizard
to create a nonvisual object that launches Dbmlsync.exe.
You can include an MLSync system object in your applications:
-
Programmatically with PowerScript
-
By selecting it from the New dialog box
Adding an MLSync object programatically
The code fragment below creates an instance of an MLSync object
and programmatically populates all of the necessary properties—as
well as some optional properties—using an instance of the
system SyncParm structure. Then it calls the Synchronize function
to start the database synchronization.
1 |
SyncParm Parms |
1 |
MLSync mySync |
1 |
Long rc |
1 |
1 |
mySync = CREATE MLSync |
1 |
mySync.MLServerVersion = 11 // required property |
1 |
mySync.Publication = 'salesapi '// required property |
1 |
mySync.UseLogFile = TRUE // optional |
1 |
mySync.LogFileName = "C: empsync.log "// optional |
1 |
mySync.Datasource = 'salesdb_remote '// required |
1 |
Parms.MLUser = '50 '// required |
1 |
Parms.MLPass = 'xyz123 '// required |
1 |
//The following values are required if they are not |
1 |
//set by the DSN |
1 |
Parms.DBUser = 'dba ' |
1 |
Parms.DBPass = 'sql ' |
1 |
1 |
// Apply the property values to the sync object |
1 |
mySync.SetParm(Parms) |
1 |
// Launch the synchronization process |
1 |
rc = mySync.Synchronize() |
1 |
destroy mySync |
Adding an MLSync object from the New dialog box
You can add an MLSync object to a target PBL using the New
dialog box: from the PowerBuilder menu, choose File>New,
go to the PB Object tab, select Standard Class, then MLSync. This
opens a new MLSync object in the User Object painter, where you
can initialize all or some of the properties. When you are finished,
you can save it as a new object in your target PBL.
Since all of the properties are already initialized, including
userids and passwords, it is ready for immediate use. To launch
a synchronization requires very little coding, as this example for
an MLsync object that you save as “nvo_my_mlsync” illustrates:
1 |
nvo_my_mlsync mySync |
1 |
Long rc |
1 |
mySync = CREATE nvo_my_mlsync |
1 |
mySync.Synchronize() |
1 |
destroy mySync |
You would typically add the above code to the Clicked event
for a menu item or a command button on one of the application windows.
For more information
For more information on system objects related to synchronization,
and their functions, events, and properties, see MLSynchronization,
MLSync, and SyncParm in the online Help.