Apply メソッド (SqlConnection)

メモ : この API は、互換性のために残されています。

指定された接続を使用して、準備スクリプトを SQL Server データベースに適用します。

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

構文

'宣言
<ObsoleteAttribute("Use Constructor with SqlConnection and Apply()")> _
Public Sub Apply ( _
    connection As SqlConnection _
)
'使用
Dim instance As SqlSyncScopeProvisioning
Dim connection As SqlConnection

instance.Apply(connection)
[ObsoleteAttribute("Use Constructor with SqlConnection and Apply()")]
public void Apply(
    SqlConnection connection
)
[ObsoleteAttribute(L"Use Constructor with SqlConnection and Apply()")]
public:
void Apply(
    SqlConnection^ connection
)
[<ObsoleteAttribute("Use Constructor with SqlConnection and Apply()")>]
member Apply : 
        connection:SqlConnection -> unit 
public function Apply(
    connection : SqlConnection
)

パラメーター

例外

例外 条件
ArgumentNullException

connection が null Nothing nullptr unit NULL 参照 (Visual Basic では Nothing) です。

次のコード例は、filtered_customer スコープ用に準備オブジェクトを作成し、ベース テーブルがサーバー データベースに作成されないように指定します。さらに、同期に関連するオブジェクトはすべて "Sync" という名前のデータベース スキーマ内で作成されるように指定します。スコープを準備する処理の一環として、Customer テーブルに対するフィルターを定義します。このフィルターに一致した行だけが同期されます。CustomerContact テーブルにはフィルターを定義しません。したがって、このテーブルのすべての行が同期されます。準備オプションを定義した後、Apply メソッドを呼び出して、サーバー データベースに変更追跡インフラストラクチャを作成します。さらに、準備スクリプトをファイルに書き込みます。完全なコンテキスト例でこのコードを表示するには、「方法: データベース同期を構成して実行する (SQL Server)」を参照してください。

SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning(serverConn, scopeDesc);
serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);
serverConfig.ObjectSchema = "Sync";

// Specify which column(s) in the Customer table to use for filtering data, 
// and the filtering clause to use against the tracking table.
// "[side]" is an alias for the tracking table.
serverConfig.Tables["Sales.Customer"].AddFilterColumn("CustomerType");
serverConfig.Tables["Sales.Customer"].FilterClause = "[side].[CustomerType] = 'Retail'";

// Configure the scope and change-tracking infrastructure.
serverConfig.Apply();

// Write the configuration script to a file. You can modify 
// this script if necessary and run it against the server
// to customize behavior.
File.WriteAllText("SampleConfigScript.txt",
    serverConfig.Script());
Dim serverConfig As New SqlSyncScopeProvisioning(serverConn, scopeDesc)
serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip)
serverConfig.ObjectSchema = "Sync"

' Specify which column(s) in the Customer table to use for filtering data, 
' and the filtering clause to use against the tracking table. 
' "[side]" is an alias for the tracking table. 
serverConfig.Tables("Sales.Customer").AddFilterColumn("CustomerType")
serverConfig.Tables("Sales.Customer").FilterClause = "[side].[CustomerType] = 'Retail'"

' Configure the scope and change-tracking infrastructure. 
serverConfig.Apply()

' Write the configuration script to a file. You can modify 
' this script if necessary and run it against the server 
' to customize behavior. 
File.WriteAllText("SampleConfigScript.txt", serverConfig.Script())

参照

参照

SqlSyncScopeProvisioningクラス

SqlSyncScopeProvisioning メンバー

Apply オーバーロード

Microsoft.Synchronization.Data.SqlServer 名前空間