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 - Server Administration » Writing Synchronization Scripts in .NET » MobiLink server API for .NET reference

GetDownloadTableByName method Next Page

DownloadTableData interface


interface DownloadTableData


Encapsulates information for one download table for a synchronization. Use this interface to set the data operations that will be downloaded to a synchronization client site.


For example, suppose you have the following table:

CREATE TABLE remoteOrders (
     pk  INT NOT NULL,
     col1 VARCHAR(200),
     PRIMARY KEY ( pk )

The following example uses the DownloadData.GetDownloadTableByName method to return a DownloadTableData instance representing the remoteOrders table.

// The method used for the handle_DownloadData event
public void HandleDownload() {
  // _cc is a DBConnectionContext instance.

  // Get the DownloadData for the current synchronization.
  DownloadData my_dd = _cc.GetDownloadData();
  // Get the DownloadTableData for the remoteOrders table.
  DownloadTableData td = my_dd.GetDownloadTableByName("remoteOrders");

  // User defined-methods to set download operations.

  // ... 

In this example, the SetDownloadInserts method uses DownloadTableData.GetUpsertCommand to obtain a command for the rows you want to insert or update. The IDbCommand holds the parameters that you will set to the values you want inserted on the remote database.

void SetDownloadInserts( DownloadTableData td ) { 
      IDbCommand  upsert_cmd = td.GetUpsertCommand();
      IDataParametersCollection parameters = upsert_cmd.Parameters;
     // The following method calls are the same as the following SQL statement:
     // INSERT INTO remoteOrders(pk, col1) values( 2300, "truck" );
      parameters[0] = 2300;
      parameters[1] = "truck";

 if( upsert_cmd.ExecuteNonQuery() > 0 ) {
         // Insert was not filtered.
     } else {
         // Insert was filtered because it was uploaded
         // in the same synchronization.

The SetDownloadDeletes method uses the DownloadTableData.GetDeleteCommand to obtain a command for rows you want to delete.

void SetDownloadDeletes( DownloadTableData td ) { 
   IDbCommand  delete_cmd = t2_download_dd.GetDeleteCommand();
  // The following method calls are the same as the following SQL statement:
  // DELETE FROM remoteOrders  where pk=2300;
  IDataParameterCollection parameters = delete_cmd.Parameters;
  parameters[0] =  2300;

GetDeleteCommand method
GetName method
GetSchemaTable method
GetUpsertCommand method