Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SyncAdapter.DeleteCommand Property

Synchronization Services - ADO.NET 1.0 SP1

Gets or sets the query or stored procedure that is used to delete data from the server database.

Namespace: Microsoft.Synchronization.Data.Server
Assembly: Microsoft.Synchronization.Data.Server (in microsoft.synchronization.data.server.dll)

public IDbCommand DeleteCommand { get; set; }
/** @property */
public IDbCommand get_DeleteCommand ()

/** @property */
public void set_DeleteCommand (IDbCommand value)

public function get DeleteCommand () : IDbCommand

public function set DeleteCommand (value : IDbCommand)

Property Value

An IDbCommand object that contains a query or stored procedure.

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.

The following code example creates a command that deletes rows from the Customer table in bidirectional and upload-only synchronization scenarios. The command is a stored procedure that is defined in Setup Scripts for Sync Services How-to Topics. To view this code in the context of a complete example, see How to: Handle Data Conflicts and Errors.

SqlCommand customerDeletes = new SqlCommand();
customerDeletes.CommandType = CommandType.StoredProcedure;
customerDeletes.CommandText = "usp_CustomerApplyDelete";
customerDeletes.Parameters.Add("@" + SyncSession.SyncLastReceivedAnchor, SqlDbType.Timestamp);
customerDeletes.Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier);
customerDeletes.Parameters.Add("@" + SyncSession.SyncForceWrite, SqlDbType.Bit);           
customerDeletes.Parameters.Add("@" + SyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output;
customerDeletes.Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier);
customerDeletes.Connection = serverConn;
customerSyncAdapter.DeleteCommand = customerDeletes;

© 2015 Microsoft