ReplicationDatabase.TransPublications ReplicationDatabase.TransPublications ReplicationDatabase.TransPublications Property

정의

복제 데이터베이스에 정의된 트랜잭션 또는 스냅숏 게시를 반환합니다. Returns the transactional or snapshot publications defined on the replication database.

public:
 property Microsoft::SqlServer::Replication::TransPublicationCollection ^ TransPublications { Microsoft::SqlServer::Replication::TransPublicationCollection ^ get(); };
public Microsoft.SqlServer.Replication.TransPublicationCollection TransPublications { get; }
Public ReadOnly Property TransPublications As TransPublicationCollection
속성 값

예제

// Define the Publisher, publication database, 
// and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2012";

TransPublication publication;
ReplicationDatabase publicationDb;

// Create a connection to the Publisher 
// using Windows Authentication.
ServerConnection conn = new ServerConnection(publisherName);

try
{
	conn.Connect();

	// Set the required properties for the transactional publication.
	publication = new TransPublication();
	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 transactional publications exists,
	// disable publishing on the database.
	publicationDb = new ReplicationDatabase(publicationDbName, conn);
	if (publicationDb.LoadProperties())
	{
		if (publicationDb.TransPublications.Count == 0)
		{
			publicationDb.EnabledTransPublishing = 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 = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"

Dim publication As TransPublication
Dim publicationDb As ReplicationDatabase

' Create a connection to the Publisher 
' using Windows Authentication.
Dim conn As ServerConnection = New ServerConnection(publisherName)

Try
    conn.Connect()

    ' Set the required properties for the transactional publication.
    publication = New TransPublication()
    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 transactional publications exists,
    ' disable publishing on the database.
    publicationDb = New ReplicationDatabase(publicationDbName, conn)
    If publicationDb.LoadProperties() Then
        If publicationDb.TransPublications.Count = 0 Then
            publicationDb.EnabledTransPublishing = 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

설명

TransPublication 개체에 TransPublicationCollection 문자열 인덱서 (이름) 또는 숫자 인덱서 (서 수)를 사용 하 여 액세스할 수 있습니다.TransPublication objects in a TransPublicationCollection can be accessed using a string indexer (name) or a numeric indexer (ordinal).

TransPublications 의 멤버 속성을 검색할 수는 sysadmin 고정된 서버 역할의 멤버 또는 db_owner 게시 데이터베이스의 고정된 데이터베이스 역할입니다.The TransPublications property can be retrieved by members of the sysadmin fixed server role or by members of the db_owner fixed database role on the publication database.

적용 대상

추가 정보