Encapsulates information for one download table for a synchronization.
Public Interface DownloadTableData
public interface DownloadTableData
All members of DownloadTableData interface, including all inherited members.
Name | Description |
---|---|
Get a command which allows the user to add delete operations to the download data operations. | |
Returns the last download time for this table. | |
Gets the table name of this instance. | |
Gets a DataTable that describes the metadata for this download table. | |
Get a command which allows the user to add upsert(insert/update) operations to the download data operations. |
Encapsulates table operations for MobiLink direct downloads. Use this interface to set the data operations that are downloaded to the client. To obtain DownloadTableData instances for the current synchronization, use the DownloadData interface. You can use the DownloadTableData.GetUpsertCommand and GetDeleteCommand methods to obtain IDbCommand objects for insert and update, and delete operations, respectively. The System.Data.IDbCommand.ExecuteNonQuery() method registers an operation for download.
Suppose you have the following table:
CREATE TABLE remoteOrders ( pk INT NOT NULL, col1 VARCHAR(200), PRIMARY KEY (pk) ); |
The following example uses the 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 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 following 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
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |