SyncAdapter.UpdateCommand Property
Gets or sets the query or stored procedure that is used to update data in the server database.
Namespace: Microsoft.Synchronization.Data.Server
Assembly: Microsoft.Synchronization.Data.Server (in microsoft.synchronization.data.server.dll)
Syntax
'Declaration
Public Property UpdateCommand As IDbCommand
public IDbCommand UpdateCommand { get; set; }
public:
property IDbCommand^ UpdateCommand {
IDbCommand^ get ();
void set (IDbCommand^ value);
}
/** @property */
public IDbCommand get_UpdateCommand ()
/** @property */
public void set_UpdateCommand (IDbCommand value)
public function get UpdateCommand () : IDbCommand
public function set UpdateCommand (value : IDbCommand)
Property Value
An IDbCommand object that contains a query or stored procedure.
Remarks
Synchronization adapter commands enable you to specify the queries and stored procedures that are used to select from and apply changes to the server database. For more information, see How to: Specify Snapshot, Download, Upload, and Bidirectional Synchronization. Each command uses session variables that enable you to pass values during synchronization. These variables are specified like other parameters to queries or stored procedures in ADO.NET commands. For more information, see How to: Use Session Variables.
Example
The following code example creates a command that updates rows in the Customer
table in bidirectional and upload-only synchronization scenarios. The command is a stored procedure that is defined in Setup Scripts for Synchronization Services How-to Topics. To view this code in the context of a complete example, see How to: Handle Data Conflicts and Errors.
SqlCommand customerUpdates = new SqlCommand();
customerUpdates.CommandType = CommandType.StoredProcedure;
customerUpdates.CommandText = "usp_CustomerApplyUpdate";
customerUpdates.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp);
customerUpdates.Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier);
customerUpdates.Parameters.Add("@" + SyncSession.SyncForceWrite, SqlDbType.Bit);
customerUpdates.Parameters.Add("@" + SyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output;
customerUpdates.Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier);
customerUpdates.Parameters.Add("@CustomerName", SqlDbType.NVarChar);
customerUpdates.Parameters.Add("@SalesPerson", SqlDbType.NVarChar);
customerUpdates.Parameters.Add("@CustomerType", SqlDbType.NVarChar);
customerUpdates.Connection = serverConn;
customerSyncAdapter.UpdateCommand = customerUpdates;
Dim customerUpdates As New SqlCommand()
customerUpdates.CommandType = CommandType.StoredProcedure
customerUpdates.CommandText = "usp_CustomerApplyUpdate"
customerUpdates.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp)
customerUpdates.Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier)
customerUpdates.Parameters.Add("@" + SyncSession.SyncForceWrite, SqlDbType.Bit)
customerUpdates.Parameters.Add("@" + SyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output
customerUpdates.Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier)
customerUpdates.Parameters.Add("@CustomerName", SqlDbType.NVarChar)
customerUpdates.Parameters.Add("@SalesPerson", SqlDbType.NVarChar)
customerUpdates.Parameters.Add("@CustomerType", SqlDbType.NVarChar)
customerUpdates.Connection = serverConn
customerSyncAdapter.UpdateCommand = customerUpdates
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Development Platforms
For a list of the supported platforms, see Hardware and Software Requirements (Synchronization Services).
Target Platforms
See Also
Reference
SyncAdapter Class
SyncAdapter Members
Microsoft.Synchronization.Data.Server Namespace