DbSyncAdapter::InsertCommand Property
Gets or sets the query or stored procedure that is used to insert data into the base table.
Assembly: Microsoft.Synchronization.Data (in Microsoft.Synchronization.Data.dll)
public: property IDbCommand^ InsertCommand { IDbCommand^ get (); void set (IDbCommand^ value); }
Property Value
Type: System.Data::IDbCommandAn 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 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).
The following code example creates a command that inserts rows into 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 insCustomerCmd = new SqlCommand(); insCustomerCmd.CommandType = CommandType.StoredProcedure; insCustomerCmd.CommandText = "Sync.sp_Customer_ApplyInsert"; insCustomerCmd.Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier); insCustomerCmd.Parameters.Add("@CustomerName", SqlDbType.NVarChar); insCustomerCmd.Parameters.Add("@SalesPerson", SqlDbType.NVarChar); insCustomerCmd.Parameters.Add("@CustomerType", SqlDbType.NVarChar); insCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output; adapterCustomer.InsertCommand = insCustomerCmd;
Dim insCustomerCmd As New SqlCommand() With insCustomerCmd .CommandType = CommandType.StoredProcedure .CommandText = "Sync.sp_Customer_ApplyInsert" .Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier) .Parameters.Add("@CustomerName", SqlDbType.NVarChar) .Parameters.Add("@SalesPerson", SqlDbType.NVarChar) .Parameters.Add("@CustomerType", SqlDbType.NVarChar) .Parameters.Add("@" + DbSyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output End With adapterCustomer.InsertCommand = insCustomerCmd