Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » MobiLink - Getting Started » Tutorial: Using .NET Synchronization Logic

The CustdbScripts assembly Next Page

Lesson 2: Specify class methods for events


For more information about the CustDB sample database, see Setting up the CustDB consolidated database.

CustdbScripts.dll, created in the previous lesson, encapsulates the methods UploadInsert() and DownloadCursor(). These methods contain implementation for the ULCustomer upload_insert and download_cursor events, respectively.

In this section, you specify class methods for table-level events using two approaches:

  1. Using the MobiLink Synchronization plug-in.

    You connect to the CustDB database with Sybase Central, change the language for the upload_insert script to .NET, and specify MLExample.CustdbScripts.UploadInsert to handle the event.

  2. Using the ml_add_dnet_table_script stored procedure.

    You will connect to the CustDB database with Interactive SQL and execute ml_add_dnet_table_script, specifying MLExample.CustdbScripts.DownloadCursor for the download_cursor event.

To subscribe CustdbScripts.uploadInsert() to the upload_insert event for the ULCustomer table
  1. Connect to the sample database using the MobiLink Synchronization plug-in:

  2. Change the language for the ULCustomer table upload_insert event to .NET:

  3. Enter the fully-qualified .NET method name for the upload_insert script.

  4. Exit Sybase Central.

This step used Sybase Central to specify a .NET method as the script for the ULCustomer upload_insert event.

Alternatively, you can use the ml_add_dnet_connection_script and ml_add_dnet_table_script stored procedures. Using these stored procedures is more efficient, especially if you have a large number of .NET methods to handle synchronization events.

See ml_add_dnet_connection_script and ml_add_dnet_table_script.

In the next section you connect to CustDB with Interactive SQL and execute ml_add_dnet_table_script, assigning MLExample.CustdbScripts.DownloadCursor to the download_cursor event.

To specify MLExample.CustdbScripts.DownloadCursor for the ULCustomer download_cursor event
  1. Connect to the sample database with Interactive SQL.

  2. Execute the following command in Interactive SQL:

    CALL ml_add_dnet_table_script(
    'custdb 10.0',
    'ULCustomer',
    'download_cursor',
    'MLExample.CustdbScripts.DownloadCursor');
    COMMIT;

    Following is a description of each parameter:

    ParameterDescription
    custdb 10.0The script version.
    ULCustomerThe synchronized table.
    download_cursorThe event name.
    MLExample.CustdbScripts.DownloadCursorThe fully qualified .NET method.
  3. Exit Interactive SQL.

In this lesson, you specified .NET methods to handle ULCustomer table-level events. The next lesson ensures that the MobiLink server loads the appropriate class files and the MobiLink server API.

Further reading

For more information about adding and deleting synchronization scripts, see Adding and deleting scripts.

For more information about the scripts used in this lesson, see ml_add_dnet_connection_script and ml_add_dnet_table_script.