interface DownloadTableData
为一个同步封装一个下载表的信息。使用此接口设置将被下载到同步客户端站点的数据操作。
例如,假设您具有以下表:
CREATE TABLE remoteOrders ( pk INT NOT NULL, col1 VARCHAR(200), PRIMARY KEY (pk) ); |
以下示例使用 DownloadData.GetDownloadTableByName 方法返回表示 remoteOrders 表的 DownloadTableData 实例。
// 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); // ... } |
在本例中,SetDownloadInserts 方法使用 DownloadTableData.GetUpsertCommand 为您想要插入或更新的行获取命令。IDbCommand 将会保存一些参数,这些参数将会被设置为您要插入到远程数据库中的值。
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. } } |
SetDownloadDeletes 方法使用 DownloadTableData.GetDeleteCommand 为您想要删除的行获取命令。
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 方法
GetLastDownloadTime 方法
GetName 方法
GetSchemaTable 方法
GetUpsertCommand 方法
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |