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 方法在伺服器資料庫中建立變更追蹤基礎結構,而且佈建指令碼會寫入檔案中。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:設定及執行資料庫同步處理 (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())