ReplicationDatabase.MergePublications 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.
Restituisce le pubblicazioni di tipo merge definite sul database di replica.
public:
property Microsoft::SqlServer::Replication::MergePublicationCollection ^ MergePublications { Microsoft::SqlServer::Replication::MergePublicationCollection ^ get(); };
public Microsoft.SqlServer.Replication.MergePublicationCollection MergePublications { get; }
member this.MergePublications : Microsoft.SqlServer.Replication.MergePublicationCollection
Public ReadOnly Property MergePublications As MergePublicationCollection
Valore della proprietà
MergePublicationCollection di oggetti MergePublication.
Esempio
// Define the Publisher, publication database,
// and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksSalesOrdersMerge";
string publicationDbName = "AdventureWorks2012";
MergePublication publication;
ReplicationDatabase publicationDb;
// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);
try
{
// Connect to the Publisher.
conn.Connect();
// Set the required properties for the merge publication.
publication = new MergePublication();
publication.ConnectionContext = conn;
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
// Delete the publication, if it exists and has no subscriptions.
if (publication.LoadProperties() && !publication.HasSubscription)
{
publication.Remove();
}
else
{
// Do something here if the publication does not exist
// or has subscriptions.
throw new ApplicationException(String.Format(
"The publication {0} could not be deleted. " +
"Ensure that the publication exists and that all " +
"subscriptions have been deleted.",
publicationName, publisherName));
}
// If no other merge publications exists,
// disable publishing on the database.
publicationDb = new ReplicationDatabase(publicationDbName, conn);
if (publicationDb.LoadProperties())
{
if (publicationDb.MergePublications.Count == 0 && publicationDb.EnabledMergePublishing)
{
publicationDb.EnabledMergePublishing = false;
}
}
else
{
// Do something here if the database does not exist.
throw new ApplicationException(String.Format(
"The database {0} does not exist on {1}.",
publicationDbName, publisherName));
}
}
catch (Exception ex)
{
// Implement application error handling here.
throw new ApplicationException(String.Format(
"The publication {0} could not be deleted.",
publicationName), ex);
}
finally
{
conn.Disconnect();
}
' Define the Publisher, publication database,
' and publication names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2012"
Dim publication As MergePublication
Dim publicationDb As ReplicationDatabase
' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)
Try
' Connect to the Publisher.
conn.Connect()
' Set the required properties for the merge publication.
publication = New MergePublication()
publication.ConnectionContext = conn
publication.Name = publicationName
publication.DatabaseName = publicationDbName
' Delete the publication, if it exists and has no subscriptions.
If (publication.LoadProperties() And Not publication.HasSubscription) Then
publication.Remove()
Else
' Do something here if the publication does not exist
' or has subscriptions.
Throw New ApplicationException(String.Format( _
"The publication {0} could not be deleted. " + _
"Ensure that the publication exists and that all " + _
"subscriptions have been deleted.", _
publicationName, publisherName))
End If
' If no other merge publications exists,
' disable publishing on the database.
publicationDb = New ReplicationDatabase(publicationDbName, conn)
If publicationDb.LoadProperties() Then
If publicationDb.MergePublications.Count = 0 _
And publicationDb.EnabledMergePublishing Then
publicationDb.EnabledMergePublishing = False
End If
Else
' Do something here if the database does not exist.
Throw New ApplicationException(String.Format( _
"The database {0} does not exist on {1}.", _
publicationDbName, publisherName))
End If
Catch ex As Exception
' Implement application error handling here.
Throw New ApplicationException(String.Format( _
"The publication {0} could not be deleted.", _
publicationName), ex)
Finally
conn.Disconnect()
End Try
Commenti
MergePublication È possibile accedere agli oggetti in un MergePublicationCollection oggetto utilizzando un indicizzatore di stringhe (nome) o un indicizzatore numerico (ordinale).
La MergePublications proprietà restituisce tutte le pubblicazioni di tipo merge per i membri dei ruoli predefiniti del db_owner
database e replmonitor
. Per tutti gli altri utenti, la MergePublications proprietà restituisce solo le pubblicazioni per le quali l'utente è membro dell'elenco di accesso alla pubblicazione.