共用方式為


SyncAdapter.SelectIncrementalInsertsCommand 屬性

取得或設定用來擷取伺服器資料庫中從上一次同步處理以來所做之插入的查詢或預存程序。

命名空間: Microsoft.Synchronization.Data.Server
組件: Microsoft.Synchronization.Data.Server (在 microsoft.synchronization.data.server.dll)

語法

'宣告
Public Property SelectIncrementalInsertsCommand As IDbCommand
'用途
Dim instance As SyncAdapter
Dim value As IDbCommand

value = instance.SelectIncrementalInsertsCommand

instance.SelectIncrementalInsertsCommand = value
public IDbCommand SelectIncrementalInsertsCommand { get; set; }
public:
property IDbCommand^ SelectIncrementalInsertsCommand {
    IDbCommand^ get ();
    void set (IDbCommand^ value);
}
/** @property */
public IDbCommand get_SelectIncrementalInsertsCommand ()

/** @property */
public void set_SelectIncrementalInsertsCommand (IDbCommand value)
public function get SelectIncrementalInsertsCommand () : IDbCommand

public function set SelectIncrementalInsertsCommand (value : IDbCommand)

屬性值

包含查詢或預存程序的 IDbCommand 物件。

備註

同步處理配接器命令可讓您指定,用來從伺服器資料庫選取及套用變更的查詢和預存程序。如需詳細資訊,請參閱 HOW TO:指定快照集、下載、上傳及雙向同步處理。每一個命令都會使用同步處理期間可讓您傳遞值的工作階段變數。指定這些變數與其他參數的指定方式一樣,都是在 ADO.NET 命令中指定到查詢或預存程序中。如需詳細資訊,請參閱 HOW TO:使用工作階段變數

範例

下列程式碼範例會在雙向及僅供下載的同步處理案例中,建立可從 Customer 資料表選取已插入之資料列的命令,並在所有種類的同步處理中選取要初始化的資料表結構描述。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:處理資料衝突和錯誤

SqlCommand customerIncrInserts = new SqlCommand();
customerIncrInserts.CommandText =
    "SELECT CustomerId, CustomerName, SalesPerson, CustomerType " +
    "FROM Sales.Customer " +
    "WHERE (InsertTimestamp > @sync_last_received_anchor " +
    "AND InsertTimestamp <= @sync_new_received_anchor " +
    "AND InsertId <> @sync_client_id)";
customerIncrInserts.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp);
customerIncrInserts.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.Timestamp);
customerIncrInserts.Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier);
customerIncrInserts.Connection = serverConn;
customerSyncAdapter.SelectIncrementalInsertsCommand = customerIncrInserts;
Dim customerIncrInserts As New SqlCommand()
With customerIncrInserts
    .CommandText = _
        "SELECT CustomerId, CustomerName, SalesPerson, CustomerType " _
      & "FROM Sales.Customer " _
      & "WHERE (InsertTimestamp > @sync_last_received_anchor " _
      & "AND InsertTimestamp <= @sync_new_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.SelectIncrementalInsertsCommand = customerIncrInserts

請參閱

參考

SyncAdapter 類別
SyncAdapter 成員
Microsoft.Synchronization.Data.Server 命名空間