Article.DatabaseName 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置包含在项目中发布的数据和对象的数据库的名称。
public:
property System::String ^ DatabaseName { System::String ^ get(); void set(System::String ^ value); };
public string DatabaseName { get; set; }
member this.DatabaseName : string with get, set
Public Property DatabaseName As String
属性值
发布数据库的名称。
例外
尝试为现有项目设置 DatabaseName 属性时。
将 属性设置为 DatabaseName 值 null
、带 null
字符的值或长于 128 Unicode 字符的值时。
示例
// Define the Publisher, publication, and article names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2012";
string articleName = "Product";
string schemaOwner = "Production";
TransArticle article;
// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);
// Create a filtered transactional articles in the following steps:
// 1) Create the article with a horizontal filter clause.
// 2) Add columns to or remove columns from the article.
try
{
// Connect to the Publisher.
conn.Connect();
// Define a horizontally filtered, log-based table article.
article = new TransArticle();
article.ConnectionContext = conn;
article.Name = articleName;
article.DatabaseName = publicationDbName;
article.SourceObjectName = articleName;
article.SourceObjectOwner = schemaOwner;
article.PublicationName = publicationName;
article.Type = ArticleOptions.LogBased;
article.FilterClause = "DiscontinuedDate IS NULL";
// Ensure that we create the schema owner at the Subscriber.
article.SchemaOption |= CreationScriptOptions.Schema;
if (!article.IsExistingObject)
{
// Create the article.
article.Create();
}
else
{
throw new ApplicationException(String.Format(
"The article {0} already exists in publication {1}.",
articleName, publicationName));
}
// Create an array of column names to remove from the article.
String[] columns = new String[1];
columns[0] = "DaysToManufacture";
// Remove the column from the article.
article.RemoveReplicatedColumns(columns);
}
catch (Exception ex)
{
// Implement appropriate error handling here.
throw new ApplicationException("The article could not be created.", ex);
}
finally
{
conn.Disconnect();
}
' Define the Publisher, publication, and article names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"
Dim articleName As String = "Product"
Dim schemaOwner As String = "Production"
Dim article As TransArticle
' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)
' Create a filtered transactional articles in the following steps:
' 1) Create the article with a horizontal filter clause.
' 2) Add columns to or remove columns from the article.
Try
' Connect to the Publisher.
conn.Connect()
' Define a horizontally filtered, log-based table article.
article = New TransArticle()
article.ConnectionContext = conn
article.Name = articleName
article.DatabaseName = publicationDbName
article.SourceObjectName = articleName
article.SourceObjectOwner = schemaOwner
article.PublicationName = publicationName
article.Type = ArticleOptions.LogBased
article.FilterClause = "DiscontinuedDate IS NULL"
' Ensure that we create the schema owner at the Subscriber.
article.SchemaOption = article.SchemaOption Or _
CreationScriptOptions.Schema
If Not article.IsExistingObject Then
' Create the article.
article.Create()
Else
Throw New ApplicationException(String.Format( _
"The article {0} already exists in publication {1}.", _
articleName, publicationName))
End If
' Create an array of column names to remove from the article.
Dim columns() As String = New String(0) {}
columns(0) = "DaysToManufacture"
' Remove the column from the article.
article.RemoveReplicatedColumns(columns)
Catch ex As Exception
' Implement appropriate error handling here.
Throw New ApplicationException("The article could not be created.", ex)
Finally
conn.Disconnect()
End Try
注解
属性 DatabaseName 是读/写属性。
DatabaseName在调用 方法以在服务器上创建项目之前Create,必须设置 属性。 尝试为现有项目设置此属性会生成异常。
属性DatabaseName必须设置为非SQL Server发布的分发数据库的名称。
该 DatabaseName 属性可由发布服务器和订阅服务器 (的固定服务器角色的成员 sysadmin
检索,以便) 重新发布订阅服务器。 发布数据库上的固定数据库角色的成员 db_owner
以及属于 PAL 成员的用户也可以检索它。 MergeArticle对于 对象,也可以由分发服务器上的固定数据库角色的成员replmonitor
检索此属性。
属性 DatabaseName 可由发布服务器上的固定服务器角色的成员 sysadmin
设置。 也可以由发布数据库上的 db_owner
固定数据库角色的成员设置。
检索 DatabaseName 等效于执行事务复制或快照复制 sp_helparticle (Transact-SQL) ,或执行 sp_helpmergearticle (Transact-SQL) 以进行合并复制。
设置 DatabaseName 等效于执行事务复制或快照复制 sp_addarticle (Transact-SQL) ,或执行 sp_addmergearticle (Transact-SQL) 以进行合并复制。