DownloadTableData interface

Syntax
interface DownloadTableData
Remarks

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

Example

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.
    SetDownloadUpserts(td);
    SetDownloadDeletes(td); 

    // ... 
}

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 set to the values you want inserted on the remote database.

void SetDownloadInserts(DownloadTableData td) { 
    IDbCommand  upsert_cmd = td.GetUpsertCommand();
    IDataParameterCollection parameters = upsert_cmd.Parameters;
    
    // The following method calls are the same as the following SQL statement:
    // INSERT INTO remoteOrders(pk, col1) values(2300, "truck");
    ((IDataParameter) (parameters[0])).Value = (Int32) 2300;
    ((IDataParameter) (parameters[1])).Value = (String) "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;
    ((IDataParameter) (parameters[0])).Value = (Int32) 2300;
    delete_cmd.ExecuteNonQuery();
}

GetDeleteCommand method
GetLastDownloadTime method
GetName method
GetSchemaTable method
GetUpsertCommand method