共用方式為


DbSyncProvider.SelectNewTimestampCommand 屬性

取得或設定 IDbCommand 物件,此物件包含從對等資料庫傳回新時間戳記值的查詢或預存程序 (Stored Procedure)。此時間戳記會定義目前工作階段 (Session) 期間要同步處理之變更集的上限 (Upper Bound)。

此屬性與 CLS 不相容。  

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

語法

'宣告
Public Overridable Property SelectNewTimestampCommand As IDbCommand
'用途
Dim instance As DbSyncProvider
Dim value As IDbCommand

value = instance.SelectNewTimestampCommand

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

/** @property */
public void set_SelectNewTimestampCommand (IDbCommand value)
public function get SelectNewTimestampCommand () : IDbCommand

public function set SelectNewTimestampCommand (value : IDbCommand)

屬性值

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

備註

為此命令指定的查詢或預存程序會傳回 timestamp 值,用來選取及套用變更集至每個對等。在目前的同步處理工作階段期間,此命令會提供新的 timestamp 值。上次同步處理工作階段 timestamp 值之後的變更,與新 timestamp 值之前的變更會進行同步處理。然後新值會儲存並用來做為下一個工作階段的起點。

範例

下列程式碼範例會指定命令,從對等擷取新的 timestamp 值。在此情況下,MIN_ACTIVE_ROWVERSION 會從 SQL Server 資料庫傳回 timestamp 值 (MIN_ACTIVE_ROWVERSION 已在 SQL Server 2005 Service Pack 2 中導入)。使用 timestamp 值的原因,是因為對等資料庫中的追蹤資料行包含 timestamp 值。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:佈建伺服器資料庫來進行共同作業同步處理 (非 SQL Server)

SqlCommand selectNewTimestampCommand = new SqlCommand();
string newTimestampVariable = "@" + DbSyncSession.SyncNewTimestamp;
selectNewTimestampCommand.CommandText = "SELECT " + newTimestampVariable + " = min_active_rowversion() - 1";
selectNewTimestampCommand.Parameters.Add(newTimestampVariable, SqlDbType.Timestamp);
selectNewTimestampCommand.Parameters[newTimestampVariable].Direction = ParameterDirection.Output;

sampleProvider.SelectNewTimestampCommand = selectNewTimestampCommand;
Dim newTimestampVariable As String = "@" + DbSyncSession.SyncNewTimestamp

Dim selectNewTimestampCommand As New SqlCommand()

With selectNewTimestampCommand
    .CommandText = "SELECT " + newTimestampVariable + " = min_active_rowversion() - 1"
    .Parameters.Add(newTimestampVariable, SqlDbType.Timestamp)
    .Parameters(newTimestampVariable).Direction = ParameterDirection.Output
End With

sampleProvider.SelectNewTimestampCommand = selectNewTimestampCommand

請參閱

參考

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