SyncAdapter.SelectIncrementalUpdatesCommand 屬性
命名空間: Microsoft.Synchronization.Data.Server
組件: Microsoft.Synchronization.Data.Server (在 microsoft.synchronization.data.server.dll)
語法
'宣告
Public Property SelectIncrementalUpdatesCommand As IDbCommand
'用途
Dim instance As SyncAdapter
Dim value As IDbCommand
value = instance.SelectIncrementalUpdatesCommand
instance.SelectIncrementalUpdatesCommand = value
public IDbCommand SelectIncrementalUpdatesCommand { get; set; }
public:
property IDbCommand^ SelectIncrementalUpdatesCommand {
IDbCommand^ get ();
void set (IDbCommand^ value);
}
/** @property */
public IDbCommand get_SelectIncrementalUpdatesCommand ()
/** @property */
public void set_SelectIncrementalUpdatesCommand (IDbCommand value)
public function get SelectIncrementalUpdatesCommand () : IDbCommand
public function set SelectIncrementalUpdatesCommand (value : IDbCommand)
屬性值
包含查詢或預存程序的 IDbCommand 物件。
備註
同步處理配接器命令可讓您指定,用來從伺服器資料庫選取及套用變更的查詢和預存程序。如需詳細資訊,請參閱 HOW TO:指定快照集、下載、上傳及雙向同步處理。每一個命令都會使用同步處理期間可讓您傳遞值的工作階段變數。指定這些變數與其他參數的指定方式一樣,都是在 ADO.NET 命令中指定到查詢或預存程序中。如需詳細資訊,請參閱 HOW TO:使用工作階段變數。
範例
下列程式碼範例會在雙向及僅供下載的同步處理案例中,建立可從 Customer
資料表選取已更新之資料列的命令。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:處理資料衝突和錯誤。
SqlCommand customerIncrUpdates = new SqlCommand();
customerIncrUpdates.CommandText =
"SELECT CustomerId, CustomerName, SalesPerson, CustomerType " +
"FROM Sales.Customer " +
"WHERE (UpdateTimestamp > @sync_last_received_anchor " +
"AND UpdateTimestamp <= @sync_new_received_anchor " +
"AND UpdateId <> @sync_client_id " +
"AND NOT (InsertTimestamp > @sync_last_received_anchor " +
"AND InsertId <> @sync_client_id))";
customerIncrUpdates.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp);
customerIncrUpdates.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.Timestamp);
customerIncrUpdates.Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier);
customerIncrUpdates.Connection = serverConn;
customerSyncAdapter.SelectIncrementalUpdatesCommand = customerIncrUpdates;
Dim customerIncrUpdates As New SqlCommand()
With customerIncrUpdates
.CommandText = _
"SELECT CustomerId, CustomerName, SalesPerson, CustomerType " _
& "FROM Sales.Customer " _
& "WHERE (UpdateTimestamp > @sync_last_received_anchor " _
& "AND UpdateTimestamp <= @sync_new_received_anchor " _
& "AND UpdateId <> @sync_client_id " _
& "AND NOT (InsertTimestamp > @sync_last_received_anchor " _
& "AND InsertId <> @sync_client_id))"
.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp)
.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.Timestamp)
.Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier)
.Connection = serverConn
End With
customerSyncAdapter.SelectIncrementalUpdatesCommand = customerIncrUpdates
請參閱
參考
SyncAdapter 類別
SyncAdapter 成員
Microsoft.Synchronization.Data.Server 命名空間