Share via


DbSyncAdapter.DeleteCommand Property

Gets or sets the query or stored procedure that is used to delete data from the base table.

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

Syntax

'Declaration
Public Property DeleteCommand As IDbCommand
'Usage
Dim instance As DbSyncAdapter
Dim value As IDbCommand

value = instance.DeleteCommand

instance.DeleteCommand = value
public IDbCommand DeleteCommand { get; set; }
public:
property IDbCommand^ DeleteCommand {
    IDbCommand^ get ();
    void set (IDbCommand^ value);
}
/** @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.

Remarks

Synchronization adapter commands enable you to specify the queries and stored procedures that are used to select from and apply data and metadata changes to a peer database. For more information, see How to: Provision a Server Database for Collaborative Synchronization (Non-SQL Server). 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 for Collaborative Synchronization (Non-SQL Server).

Example

The following code example creates a command that deletes rows from the Customer table at a peer. The command is a stored procedure that is defined in Setup Scripts for Database Provider How-to Topics. 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 delCustomerCmd = new SqlCommand();
delCustomerCmd.CommandType = CommandType.StoredProcedure;
delCustomerCmd.CommandText = "Sync.sp_Customer_ApplyDelete";
delCustomerCmd.Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier);
delCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncMinTimestamp, SqlDbType.BigInt);
delCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output;
delCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncForceWrite, SqlDbType.Int);

adapterCustomer.DeleteCommand = delCustomerCmd;
Dim delCustomerCmd As New SqlCommand()

With delCustomerCmd
    .CommandType = CommandType.StoredProcedure
    .CommandText = "Sync.sp_Customer_ApplyDelete"
    .Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier)
    .Parameters.Add("@" + DbSyncSession.SyncMinTimestamp, SqlDbType.BigInt)
    .Parameters.Add("@" + DbSyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output
    .Parameters.Add("@" + DbSyncSession.SyncForceWrite, SqlDbType.Int)
End With

adapterCustomer.DeleteCommand = delCustomerCmd

See Also

Reference

DbSyncAdapter Class
DbSyncAdapter Members
Microsoft.Synchronization.Data Namespace