Script メソッド (String)
メモ : この API は、互換性のために残されています。
特定のスコープに対応するデータベースを準備するための SQL コードを格納する文字列を生成します。
名前空間: Microsoft.Synchronization.Data.SqlServer
アセンブリ: Microsoft.Synchronization.Data.SqlServer (Microsoft.Synchronization.Data.SqlServer.dll 内)
構文
'宣言
<ObsoleteAttribute("Use Constructor with SqlConnection and Script()")> _
Public Function Script ( _
targetDatabaseName As String _
) As String
'使用
Dim instance As SqlSyncScopeProvisioning
Dim targetDatabaseName As String
Dim returnValue As String
returnValue = instance.Script(targetDatabaseName)
[ObsoleteAttribute("Use Constructor with SqlConnection and Script()")]
public string Script(
string targetDatabaseName
)
[ObsoleteAttribute(L"Use Constructor with SqlConnection and Script()")]
public:
String^ Script(
String^ targetDatabaseName
)
[<ObsoleteAttribute("Use Constructor with SqlConnection and Script()")>]
member Script :
targetDatabaseName:string -> string
public function Script(
targetDatabaseName : String
) : String
パラメーター
- targetDatabaseName
型 : System. . :: . .String
準備スクリプトを生成する対象のデータベースの名前。
戻り値
型 : System. . :: . .String
特定のスコープに対応するデータベースを準備するための SQL コード。
例外
例外 | 条件 |
---|---|
ArgumentException | targetDatabaseName が 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())