DbSyncProvider.SelectNewTimestampCommand Property

Gets or sets an IDbCommand object that contains the query or stored procedure that returns a new timestamp value from the peer database. The timestamp defines the upper bound for the set of changes to be synchronized during the current session.

Namespace:  Microsoft.Synchronization.Data
Assembly:  Microsoft.Synchronization.Data (in Microsoft.Synchronization.Data.dll)

Syntax

'Declaration
Public Overridable Property SelectNewTimestampCommand As IDbCommand
    Get
    Set
'Usage
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);
}
abstract SelectNewTimestampCommand : IDbCommand with get, set
override SelectNewTimestampCommand : IDbCommand with get, set
function get SelectNewTimestampCommand () : IDbCommand
function set SelectNewTimestampCommand (value : IDbCommand)

Property Value

Type: System.Data.IDbCommand
An IDbCommand object that contains a query or stored procedure.

Remarks

The query or stored procedure that is specified for this command returns a timestamp value that is used to select and apply sets of changes to each peer. During the current synchronization session, the command provides a new timestamp value. Changes that are made after the timestamp value from the previous synchronization session and before the new timestamp value are synchronized. The new value is then stored and used as the starting point for the next session.

Examples

The following code example specifies a command to retrieve a new timestamp value from a peer. In this case, MIN_ACTIVE_ROWVERSION returns a timestamp value from a SQL Server database. (MIN_ACTIVE_ROWVERSION was introduced in SQL Server 2005 Service Pack 2.) A timestamp value is used because the tracking columns in the peer database contain timestamp values. To view this code in the context of a complete example, see How to: Provision a Server Database for Collaborative Synchronization (Non-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

See Also

Reference

DbSyncProvider Class

Microsoft.Synchronization.Data Namespace