TransPublication Klasse

Definition

Stellt eine transaktionale Publikation dar.

public ref class TransPublication sealed : Microsoft::SqlServer::Replication::Publication
public sealed class TransPublication : Microsoft.SqlServer.Replication.Publication
type TransPublication = class
    inherit Publication
Public NotInheritable Class TransPublication
Inherits Publication
Vererbung

Beispiele

Dieses Beispiel erzeugt eine transaktionale Publikation.

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

ReplicationDatabase publicationDb;
TransPublication publication;

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


try
{
    // Connect to the Publisher.
    conn.Connect();

    // Enable the AdventureWorks2012 database for transactional publishing.
    publicationDb = new ReplicationDatabase(publicationDbName, conn);

    // If the database exists and is not already enabled, 
    // enable it for transactional publishing.
    if (publicationDb.LoadProperties())
    {
        if (!publicationDb.EnabledTransPublishing)
        {
            publicationDb.EnabledTransPublishing = true;
        }

        // If the Log Reader Agent does not exist, create it.
        if (!publicationDb.LogReaderAgentExists)
        {
            // Specify the Windows account under which the agent job runs.
            // This account will be used for the local connection to the 
            // Distributor and all agent connections that use Windows Authentication.
            publicationDb.LogReaderAgentProcessSecurity.Login = winLogin;
            publicationDb.LogReaderAgentProcessSecurity.Password = winPassword;

            // Explicitly set authentication mode for the Publisher connection
            // to the default value of Windows Authentication.
            publicationDb.LogReaderAgentPublisherSecurity.WindowsAuthentication = true;

            // Create the Log Reader Agent job.
            publicationDb.CreateLogReaderAgent();
        }
    }
    else
    {
        throw new ApplicationException(String.Format(
            "The {0} database does not exist at {1}.",
            publicationDb, publisherName));
    }

    // Set the required properties for the transactional publication.
    publication = new TransPublication();
    publication.ConnectionContext = conn;
    publication.Name = publicationName;
    publication.DatabaseName = publicationDbName;

    // Specify a transactional publication (the default).
    publication.Type = PublicationType.Transactional;

    // Activate the publication so that we can add subscriptions.
    publication.Status = State.Active;

    // Enable push and pull subscriptions and independent Distribition Agents.
    publication.Attributes |= PublicationAttributes.AllowPull;
    publication.Attributes |= PublicationAttributes.AllowPush;
    publication.Attributes |= PublicationAttributes.IndependentAgent;

    // Specify the Windows account under which the Snapshot Agent job runs.
    // This account will be used for the local connection to the 
    // Distributor and all agent connections that use Windows Authentication.
    publication.SnapshotGenerationAgentProcessSecurity.Login = winLogin;
    publication.SnapshotGenerationAgentProcessSecurity.Password = winPassword;

    // Explicitly set the security mode for the Publisher connection
    // Windows Authentication (the default).
    publication.SnapshotGenerationAgentPublisherSecurity.WindowsAuthentication = true;

    if (!publication.IsExistingObject)
    {
        // Create the transactional publication.
        publication.Create();

        // Create a Snapshot Agent job for the publication.
        publication.CreateSnapshotAgent();
    }
    else
    {
        throw new ApplicationException(String.Format(
            "The {0} publication already exists.", publicationName));
    }
}

catch (Exception ex)
{
    // Implement custom application error handling here.
    throw new ApplicationException(String.Format(
        "The publication {0} could not be created.", publicationName), ex);
}
finally
{
    conn.Disconnect();
}
' Set the Publisher, publication database, and publication names.
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"
Dim publisherName As String = publisherInstance

Dim publicationDb As ReplicationDatabase
Dim publication As TransPublication

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

Try
    ' Connect to the Publisher.
    conn.Connect()

    ' Enable the AdventureWorks2012 database for transactional publishing.
    publicationDb = New ReplicationDatabase(publicationDbName, conn)

    ' If the database exists and is not already enabled, 
    ' enable it for transactional publishing.
    If publicationDb.LoadProperties() Then
        If Not publicationDb.EnabledTransPublishing Then
            publicationDb.EnabledTransPublishing = True
        End If

        ' If the Log Reader Agent does not exist, create it.
        If Not publicationDb.LogReaderAgentExists Then
            ' Specify the Windows account under which the agent job runs.
            ' This account will be used for the local connection to the 
            ' Distributor and all agent connections that use Windows Authentication.
            publicationDb.LogReaderAgentProcessSecurity.Login = winLogin
            publicationDb.LogReaderAgentProcessSecurity.Password = winPassword

            ' Explicitly set authentication mode for the Publisher connection
            ' to the default value of Windows Authentication.
            publicationDb.LogReaderAgentPublisherSecurity.WindowsAuthentication = True

            ' Create the Log Reader Agent job.
            publicationDb.CreateLogReaderAgent()
        End If
    Else
        Throw New ApplicationException(String.Format( _
         "The {0} database does not exist at {1}.", _
         publicationDb, publisherName))
    End If

    ' Set the required properties for the transactional publication.
    publication = New TransPublication()
    publication.ConnectionContext = conn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName

    ' Specify a transactional publication (the default).
    publication.Type = PublicationType.Transactional

    'Enable push and pull subscriptions and independent Distribition Agents.
    publication.Attributes = _
    publication.Attributes Or PublicationAttributes.AllowPull
    publication.Attributes = _
    publication.Attributes Or PublicationAttributes.AllowPush
    publication.Attributes = _
    publication.Attributes Or PublicationAttributes.IndependentAgent

    ' Activate the publication so that we can add subscriptions.
    publication.Status = State.Active

    ' Specify the Windows account under which the Snapshot Agent job runs.
    ' This account will be used for the local connection to the 
    ' Distributor and all agent connections that use Windows Authentication.
    publication.SnapshotGenerationAgentProcessSecurity.Login = winLogin
    publication.SnapshotGenerationAgentProcessSecurity.Password = winPassword

    ' Explicitly set the security mode for the Publisher connection
    ' Windows Authentication (the default).
    publication.SnapshotGenerationAgentPublisherSecurity.WindowsAuthentication = True

    If Not publication.IsExistingObject Then
        ' Create the transactional publication.
        publication.Create()

        ' Create a Snapshot Agent job for the publication.
        publication.CreateSnapshotAgent()
    Else
        Throw New ApplicationException(String.Format( _
            "The {0} publication already exists.", publicationName))
    End If
Catch ex As Exception
    ' Implement custom application error handling here.
    Throw New ApplicationException(String.Format( _
        "The publication {0} could not be created.", publicationName), ex)
Finally
    conn.Disconnect()
End Try

Dieses Beispiel löscht eine transaktionale Veröffentlichung.

// 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

Hinweise

Threadsicherheit

Alle öffentlichen statischen (Shared in Microsoft Visual Basic) Mitglieder dieses Typs sind für Multithread-Operationen sicher. Instanzenmitglieder sind nicht garantiert threadsicher.

Konstruktoren

Name Beschreibung
TransPublication()

Erstellt eine neue Instanz der TransPublication Klasse.

TransPublication(String, String, ServerConnection, Boolean)

Erstellt eine neue Instanz der TransPublication Klasse mit den erforderlichen Eigenschaften und gibt an, ob der Momentaufnahmen-Agent-Job für die Veröffentlichung erstellt wurde.

TransPublication(String, String, ServerConnection)

Erstellt eine neue Instanz der TransPublication Klasse mit den erforderlichen Eigenschaften.

Eigenschaften

Name Beschreibung
AltSnapshotFolder

Er erhält oder setzt den alternativen Snapshot-Dateistandort für eine Veröffentlichung.

(Geerbt von Publication)
Attributes

Erhält oder setzt die Veröffentlichungsattribute.

(Geerbt von Publication)
CachePropertyChanges

Es gibt oder setzt, ob Änderungen an den Replikationseigenschaften zwischengespeichert oder sofort angewendet werden.

(Geerbt von ReplicationObject)
CompatibilityLevel

Erhält oder setzt die früheste Version des Microsoft SQL Server, die auf den Abonnenten läuft und die die referenzierte Publikation unterstützen kann.

(Geerbt von Publication)
ConflictPolicy

Erhält oder setzt die Konfliktrichtlinie für Publikationen, die das Aktualisieren von Abonnements unterstützen.

ConflictRetention

Erhält oder legt die Anzahl der Tage fest, an denen Konfliktdatenzeilen in Konflikttabellen gespeichert werden.

(Geerbt von Publication)
ConnectionContext

Erhält oder setzt die Verbindung zu einer Instanz von Microsoft SQL Server.

(Geerbt von ReplicationObject)
ContinueOnConflict

Legt fest, ob der Verteilungs-Agent nach Erkennung eines Konflikts die Verarbeitung von Änderungen fortsetzt.

CreateSnapshotAgentByDefault

Erhält oder setzt, ob der Momentaufnahmen-Agent-Job automatisch hinzugefügt wird, wenn die Veröffentlichung erstellt wird.

(Geerbt von Publication)
DatabaseName

Erhält oder setzt den Namen der Publikationsdatenbank.

(Geerbt von Publication)
Description

Beschafft oder setzt eine Textbeschreibung der Veröffentlichung.

(Geerbt von Publication)
FtpAddress

Erhält oder setzt die Adresse des File Transfer Protocol (FTP)-Servercomputers für Veröffentlichungen, die eine Abonnementinitialisierung über FTP erlauben.

(Geerbt von Publication)
FtpLogin

Erhält oder setzt das Login, das zur Verbindung mit dem File Transfer Protocol (FTP)-Server für Veröffentlichungen verwendet wird, die eine Abonnementinitialisierung über FTP ermöglichen.

(Geerbt von Publication)
FtpPassword

Legt das Passwort für den Login fest, der zur Verbindung mit dem File Transfer Protocol (FTP)-Server für Veröffentlichungen verwendet wird, die eine Abonnementinitialisierung über FTP erlauben.

(Geerbt von Publication)
FtpPort

Erhält oder setzt den Port des File Transfer Protocol (FTP)-Servercomputers für Veröffentlichungen, die eine Abonnementinitialisierung über FTP ermöglichen.

(Geerbt von Publication)
FtpSubdirectory

Erhält oder setzt das Unterverzeichnis auf dem File Transfer Protocol (FTP)-Servercomputer für Veröffentlichungen, die eine Abonnementinitialisierung über FTP erlauben.

(Geerbt von Publication)
HasSubscription

Es wird ersichtlich, ob die Publikation ein oder mehrere Abonnements hat.

(Geerbt von Publication)
IsExistingObject

Es bekommt, ob das Objekt auf dem Server existiert oder nicht.

(Geerbt von ReplicationObject)
Name

Bekommt oder setzt den Namen der Publikation.

(Geerbt von Publication)
PeerConflictDetectionEnabled

Erhält ab, ob die Peer-to-Peer-Konflikterkennung durch die Verwendung SetPeerConflictDetection(Boolean, Int32)aktiviert wurde.

PeerOriginatorID

Erhält die ID eines Knotens in einer Peer-to-Peer-Topologie; diese ID wird zur Konflikterkennung verwendet, wenn PeerConflictDetectionEnabled auf truegesetzt ist.

PostSnapshotScript

Erhält oder setzt den Namen und den vollständigen Pfad einer Transact-SQL Skriptdatei, die nach der Anwendung des initialen Snapshots auf den Abonnenten ausgeführt wird.

(Geerbt von Publication)
PreSnapshotScript

Erhält oder setzt den Namen und den vollständigen Pfad einer Transact-SQL Skriptdatei, die ausgeführt wird, bevor der erste Snapshot auf den Subscriber angewendet wird.

(Geerbt von Publication)
PubId

Erhält den Wert, der die Publikation eindeutig identifiziert.

(Geerbt von Publication)
PublisherName

Erhält oder setzt den Namen der Nicht-SQL Server Publisher.

QueueType

Erhält oder legt die Art der Warteschlange fest, die für Publikationen verwendet werden soll, die Warteschlangen-Aktualisierungs-Abonnements ermöglichen.

ReplicateDdl

Erhält oder setzt die Data Definition Language (DDL)-Replikationsoptionen, die bestimmen, ob DDL-Änderungen repliziert werden.

(Geerbt von Publication)
RetentionPeriod

Bekommt oder legt die Zeit fest, bis ein Abonnement abläuft, wenn das Abonnement nicht mit der Veröffentlichung synchronisiert ist.

(Geerbt von Publication)
SecureFtpPassword

Legt das Passwort (als SecureString Objekt) für die Anmeldung fest, die zur Verbindung mit dem File Transfer Protocol (FTP)-Server für Veröffentlichungen verwendet wird, die eine Abonnementinitialisierung über FTP ermöglichen.

(Geerbt von Publication)
SnapshotAgentExists

Es gibt die Option, ob der SQL Server-Agent-Job existiert, um den initialen Snapshot für diese Veröffentlichung zu generieren.

(Geerbt von Publication)
SnapshotAvailable

Es wird herausgefunden, ob die Snapshot-Dateien dieser Veröffentlichung zur Verfügung stehen.

SnapshotGenerationAgentProcessSecurity

Erhält ein Objekt, das das Windows-Konto einlegt, unter dem der Momentaufnahmen-Agent-Job ausgeführt wird.

(Geerbt von Publication)
SnapshotGenerationAgentPublisherSecurity

Erhält den Sicherheitskontext, den der Momentaufnahmen-Agent verwendet, um sich mit dem Publisher zu verbinden.

(Geerbt von Publication)
SnapshotJobId

Erhält die Momentaufnahmen-Agent-Job-ID für die aktuelle Veröffentlichung.

(Geerbt von Publication)
SnapshotMethod

Erhält oder setzt das Dateiformat des ursprünglichen Snapshots.

(Geerbt von Publication)
SnapshotSchedule

Erhält ein Objekt, das den Zeitplan für den Momentaufnahmen-Agent für die aktuelle Veröffentlichung festlegt.

(Geerbt von Publication)
SqlServerName

Erhält den Namen der Microsoft SQL Server-Instanz, mit der dieses Objekt verbunden ist.

(Geerbt von ReplicationObject)
Status

Erhält oder bestimmt den Status der Veröffentlichung.

(Geerbt von Publication)
TransArticles

Stellt die Artikel in der Publikation dar.

TransSubscriptions

Stellt Abonnements für die Publikation dar.

Type

Erhält oder bestimmt die Art der Veröffentlichung.

(Geerbt von Publication)
UserData

Erhält oder setzt eine Objekt-Eigenschaft, die es Nutzern erlaubt, eigene Daten an das Objekt anzuhängen.

(Geerbt von ReplicationObject)

Methoden

Name Beschreibung
BrowseSnapshotFolder(String, String)

Gibt den vollständigen Pfad des Ortes zurück, an dem Snapshot-Dateien für ein bestimmtes Abonnement generiert wurden.

CheckValidCreation()

Prüft die gültige Replikationserstellung.

(Geerbt von ReplicationObject)
CheckValidDefinition(Boolean)

Gibt an, ob die gültige Definition überprüft werden soll.

(Geerbt von Publication)
CommitPropertyChanges()

Sendet alle zwischengespeicherten Property-Change-Anweisungen an die Instanz von Microsoft SQL Server.

(Geerbt von ReplicationObject)
CopySnapshot(String, String, String)

Kopiert die neuesten Snapshot-Dateien eines bestimmten Abonnements in einen Zielordner.

Create()

Erstellt die Publikation.

(Geerbt von Publication)
CreateSnapshotAgent()

Erstellt den SQL Server-Agent-Job, der zur Erstellung des initialen Snapshots für die Veröffentlichung verwendet wird, falls dieser Job noch nicht existiert.

(Geerbt von Publication)
Decouple()

Entkoppelt das referenzierte Replikationsobjekt vom Server.

(Geerbt von ReplicationObject)
EnumArticles()

Gibt die Artikel in der Publikation zurück.

(Geerbt von Publication)
EnumPublicationAccesses(Boolean)

Gibt Logins zurück, die Zugriff auf den Publisher haben.

(Geerbt von Publication)
EnumSubscriptions()

Gibt die Abonnements zurück, die die Publikation abonniert haben.

(Geerbt von Publication)
GetChangeCommand(StringBuilder, String, String)

Gibt den Änderungsbefehl aus der Replikation zurück.

(Geerbt von ReplicationObject)
GetCreateCommand(StringBuilder, Boolean, ScriptOptions)

Gibt den Create-Befehl aus der Replikation zurück.

(Geerbt von ReplicationObject)
GetDropCommand(StringBuilder, Boolean)

Gibt den Drop-Befehl aus der Replikation zurück.

(Geerbt von ReplicationObject)
GrantPublicationAccess(String)

Fügt den angegebenen Login der Publikationszugangsliste (PAL) hinzu.

(Geerbt von Publication)
InternalRefresh(Boolean)

Führt eine interne Aktualisierung aus der Replikation ein.

(Geerbt von ReplicationObject)
Load()

Lädt die Eigenschaften eines bestehenden Objekts vom Server.

(Geerbt von ReplicationObject)
LoadProperties()

Lädt die Eigenschaften eines bestehenden Objekts vom Server.

(Geerbt von ReplicationObject)
MakePullSubscriptionWellKnown(String, String, SubscriptionSyncType, TransSubscriberType, Boolean)

Stellt eine transaktionale Publikation dar.

MakePullSubscriptionWellKnown(String, String, SubscriptionSyncType, TransSubscriberType)

Meldet ein Pull-Abonnement beim Publisher an.

PostTracerToken()

Es wird ein Tracer-Token in das Publisher-Log eingetragen, um den Prozess der Bestimmung der Latenz zu beginnen.

Refresh()

Lädt die Eigenschaften des Objekts neu.

(Geerbt von ReplicationObject)
RefreshSubscriptions()

Aktualisiert alle Abonnements einer Publikation, um alle neu hinzugefügten Artikel aufzunehmen.

ReinitializeAllSubscriptions()

Markiert alle Abonnements für die Publikation zur Neuinitialisierung.

ReinitializeAllSubscriptions(Boolean)

Markiert alle Abonnements der Veröffentlichung für eine Neuinitialisierung, mit der Option, einen bestehenden Snapshot ungültig zu machen.

Remove()

Entfernt eine bestehende Veröffentlichung.

(Geerbt von Publication)
Remove(Boolean)

Entfernt eine bestehende Veröffentlichung, selbst wenn der Vertrieb nicht zugänglich ist.

(Geerbt von Publication)
RemovePullSubscription(String, String)

Entfernt die Registrierung für ein Pull-Abonnement beim Publisher.

ReplicateUserDefinedScript(String)

Repliziert die Ausführung eines benutzerdefinierten Skripts an die Abonnenten einer bestimmten Publikation.

(Geerbt von Publication)
RevokePublicationAccess(String)

Entfernt den angegebenen Login aus der Publikationszugriffsliste (PAL).

(Geerbt von Publication)
Script(ScriptOptions)

Erzeugt ein Transact-SQL Skript, das verwendet werden kann, um die Veröffentlichung gemäß den Skriptoptionen neu zu erstellen.

(Geerbt von Publication)
SetPeerConflictDetection(Boolean, Int32)

Aktiviert oder deaktiviert Konflikterkennung für einen Knoten in einer Peer-to-Peer-Topologie.

StartSnapshotGenerationAgentJob()

Startet die Aufgabe, die den ersten Schnappschuss für die Veröffentlichung erzeugt.

(Geerbt von Publication)
StopSnapshotGenerationAgentJob()

Versucht, einen laufenden Momentaufnahmen-Agent-Job zu stoppen.

(Geerbt von Publication)
ValidatePublication(ValidationOption, ValidationMethod, Boolean)

Aktiviert die Inline-Veröffentlichungsvalidierung für alle Abonnements.

ValidateSubscriptions(String[], String[], ValidationOption, ValidationMethod, Boolean)

Aktiviert die Inline-Veröffentlichungsvalidierung für das angegebene Abonnement.

Gilt für:

Weitere Informationen