Article.DatabaseName Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta il nome del database che contiene i dati e gli oggetti pubblicati nell'articolo.
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
Valore della proprietà
Nome del database di pubblicazione.
Eccezioni
Quando cerchi di impostare la DatabaseName base per un articolo esistente.
Quando imposti la DatabaseName proprietà a un null valore, a un valore con null caratteri o a un valore più lungo di 128 caratteri Unicode.
Esempio
// 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
Commenti
La DatabaseName proprietà è una proprietà di lettura/scrittura.
La DatabaseName proprietà deve essere impostata prima che il Create metodo venga chiamato per creare l'articolo sul server. Tentare di impostare questa proprietà per un articolo esistente genera un'eccezione.
La DatabaseName proprietà deve essere impostata come nome del database di distribuzione per le pubblicazioni non SQL Server.
La DatabaseName proprietà può essere recuperata dai membri del sysadmin ruolo di server fisso presso l'Publisher e dall'Abbonato (per la ripubblicazione degli Abbonati). Può anche essere recuperato dai membri del db_owner ruolo fisso nel database della pubblicazione e dagli utenti che sono membri del PAL. Per un MergeArticle oggetto, questa proprietà può essere recuperata anche dai membri del replmonitor ruolo di database fisso sul Distributore.
La DatabaseName proprietà può essere impostata dai membri del sysadmin ruolo server fisso presso l'Publisher. Può anche essere impostato dai membri del db_owner ruolo fisso del database nella banca di dati della pubblicazione.
Il recupero DatabaseName è equivalente all'esecuzione di sp_helparticle (Transact-SQL) per la replica transazionale o snapshot oppure all'esecuzione di sp_helpmergearticle (Transact-SQL) per la replica da merge.
L'impostazione DatabaseName equivale all'esecuzione di sp_addarticle (Transact-SQL) per la replica transazionale o snapshot, oppure all'esecuzione di sp_addmergearticle (Transact-SQL) per la replica da merge.