次の方法で共有


UpdateCommand プロパティ

サーバー データベースでデータを更新するために使用されるクエリまたはストアド プロシージャを取得または設定します。

名前空間:  Microsoft.Synchronization.Data.Server
アセンブリ:  Microsoft.Synchronization.Data.Server (Microsoft.Synchronization.Data.Server.dll 内)

構文

'宣言
Public Property UpdateCommand As IDbCommand
    Get
    Set
'使用
Dim instance As SyncAdapter
Dim value As IDbCommand

value = instance.UpdateCommand

instance.UpdateCommand = value
public IDbCommand UpdateCommand { get; set; }
public:
property IDbCommand^ UpdateCommand {
    IDbCommand^ get ();
    void set (IDbCommand^ value);
}
member UpdateCommand : IDbCommand with get, set
function get UpdateCommand () : IDbCommand
function set UpdateCommand (value : IDbCommand)

プロパティ値

型 : System.Data. . :: . .IDbCommand
クエリまたはストアド プロシージャを格納する IDbCommand オブジェクト。

説明

同期アダプター コマンドにより、サーバー データベースから選択しサーバー データベースに変更を適用するのに使用されるクエリとストアド プロシージャを指定できるようになります。詳細については、「スナップショット、ダウンロード、アップロード、および双方向の各同期を指定する方法」を参照してください。各コマンドは、同期中に値を渡すことができるセッション変数を使用します。これらの変数は、ADO.NET コマンドのクエリやストアド プロシージャに対する他のパラメーターと同じように指定します。詳細については、「セッション変数を使用する方法」を参照してください。

次のコード例は、双方向でアップロードのみの同期シナリオで Customer テーブルの行を更新するコマンドを作成します。コマンドは、データベース プロバイダーのセットアップ スクリプトに関するトピック で定義されているストアド プロシージャです。完全なコンテキスト例でこのコードを表示するには、「データの競合とエラーを処理する方法」を参照してください。

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

参照

参照

SyncAdapterクラス

SyncAdapter メンバー

Microsoft.Synchronization.Data.Server 名前空間