共用方式為


DbSyncAdapter.InsertMetadataCommand 屬性

取得或設定用來將中繼資料插入中繼資料表中的查詢或預存程序。

命名空間: Microsoft.Synchronization.Data
組件: Microsoft.Synchronization.Data (在 microsoft.synchronization.data.dll)

語法

'宣告
Public Property InsertMetadataCommand As IDbCommand
'用途
Dim instance As DbSyncAdapter
Dim value As IDbCommand

value = instance.InsertMetadataCommand

instance.InsertMetadataCommand = value
public IDbCommand InsertMetadataCommand { get; set; }
public:
property IDbCommand^ InsertMetadataCommand {
    IDbCommand^ get ();
    void set (IDbCommand^ value);
}
/** @property */
public IDbCommand get_InsertMetadataCommand ()

/** @property */
public void set_InsertMetadataCommand (IDbCommand value)
public function get InsertMetadataCommand () : IDbCommand

public function set InsertMetadataCommand (value : IDbCommand)

屬性值

包含查詢或預存程序的 IDbCommand 物件。

備註

同步處理配接器命令可讓您指定查詢和預存程序,用來從對等資料庫選取並套用資料和中繼資料變更至對等資料庫。如需詳細資訊,請參閱 HOW TO:佈建伺服器資料庫來進行共同作業同步處理 (非 SQL Server)。每一個命令都會使用同步處理期間可讓您傳遞值的工作階段變數。指定這些變數與其他參數的指定方式一樣,都是在 ADO.NET 命令中指定到查詢或預存程序中。如需詳細資訊,請參閱 HOW TO:使用共同作業同步處理的工作階段變數

範例

下列程式碼範例會建立命令,將資料列插入對等的 Customer_Tracking 資料表中。此命令是資料庫提供者的安裝指令碼 HOW-TO 主題中所定義的預存程序。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:佈建伺服器資料庫來進行共同作業同步處理 (非 SQL Server)

SqlCommand insMetadataCustomerCmd = new SqlCommand();
insMetadataCustomerCmd.CommandType = CommandType.StoredProcedure;
insMetadataCustomerCmd.CommandText = "Sync.sp_Customer_InsertMetadata";
insMetadataCustomerCmd.Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier);          
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncScopeLocalId, SqlDbType.Int);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncRowTimestamp, SqlDbType.BigInt);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncCreatePeerKey, SqlDbType.Int);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncCreatePeerTimestamp, SqlDbType.BigInt);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncUpdatePeerKey, SqlDbType.Int);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncUpdatePeerTimestamp, SqlDbType.BigInt);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncRowIsTombstone, SqlDbType.Int);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncCheckConcurrency, SqlDbType.Int);
insMetadataCustomerCmd.Parameters.Add("@" + DbSyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output;

adapterCustomer.InsertMetadataCommand = insMetadataCustomerCmd;
Dim insMetadataCustomerCmd As New SqlCommand()

With insMetadataCustomerCmd
    .CommandType = CommandType.StoredProcedure
    .CommandText = "Sync.sp_Customer_InsertMetadata"
    .Parameters.Add("@CustomerId", SqlDbType.UniqueIdentifier)
    .Parameters.Add("@" + DbSyncSession.SyncScopeLocalId, SqlDbType.Int)
    .Parameters.Add("@" + DbSyncSession.SyncRowTimestamp, SqlDbType.BigInt)
    .Parameters.Add("@" + DbSyncSession.SyncCreatePeerKey, SqlDbType.Int)
    .Parameters.Add("@" + DbSyncSession.SyncCreatePeerTimestamp, SqlDbType.BigInt)
    .Parameters.Add("@" + DbSyncSession.SyncUpdatePeerKey, SqlDbType.Int)
    .Parameters.Add("@" + DbSyncSession.SyncUpdatePeerTimestamp, SqlDbType.BigInt)
    .Parameters.Add("@" + DbSyncSession.SyncRowIsTombstone, SqlDbType.Int)
    .Parameters.Add("@" + DbSyncSession.SyncCheckConcurrency, SqlDbType.Int)
    .Parameters.Add("@" + DbSyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output
End With

adapterCustomer.InsertMetadataCommand = insMetadataCustomerCmd

請參閱

參考

DbSyncAdapter 類別
DbSyncAdapter 成員
Microsoft.Synchronization.Data 命名空間