TransPullSubscription.SynchronizeWithJob Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Es startet den Agentenjob, um das Abonnement zu synchronisieren.
public:
override void SynchronizeWithJob();
public override void SynchronizeWithJob();
override this.SynchronizeWithJob : unit -> unit
Public Overrides Sub SynchronizeWithJob ()
Beispiele
// Define server, publication, and database names.
String subscriberName = subscriberInstance;
String publisherName = publisherInstance;
String publicationName = "AdvWorksProductTran";
String publicationDbName = "AdventureWorks2012";
String subscriptionDbName = "AdventureWorks2012Replica";
// Create a connection to the Subscriber.
ServerConnection conn = new ServerConnection(subscriberName);
TransPullSubscription subscription;
try
{
// Connect to the Subscriber.
conn.Connect();
// Define subscription properties.
subscription = new TransPullSubscription();
subscription.ConnectionContext = conn;
subscription.DatabaseName = subscriptionDbName;
subscription.PublisherName = publisherName;
subscription.PublicationDBName = publicationDbName;
subscription.PublicationName = publicationName;
// If the pull subscription and the job exists, start the agent job.
if (subscription.LoadProperties() && subscription.AgentJobId != null)
{
subscription.SynchronizeWithJob();
}
else
{
// Do something here if the subscription does not exist.
throw new ApplicationException(String.Format(
"A subscription to '{0}' does not exists on {1}",
publicationName, subscriberName));
}
}
catch (Exception ex)
{
// Do appropriate error handling here.
throw new ApplicationException("The subscription could not be synchronized.", ex);
}
finally
{
conn.Disconnect();
}
' Define server, publication, and database names.
Dim subscriberName As String = subscriberInstance
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"
Dim subscriptionDbName As String = "AdventureWorks2012Replica"
' Create a connection to the Subscriber.
Dim conn As ServerConnection = New ServerConnection(subscriberName)
Dim subscription As TransPullSubscription
Try
' Connect to the Subscriber.
conn.Connect()
' Define subscription properties.
subscription = New TransPullSubscription()
subscription.ConnectionContext = conn
subscription.DatabaseName = subscriptionDbName
subscription.PublisherName = publisherName
subscription.PublicationDBName = publicationDbName
subscription.PublicationName = publicationName
' If the pull subscription and the job exists, start the agent job.
If subscription.LoadProperties() And Not subscription.AgentJobId Is Nothing Then
subscription.SynchronizeWithJob()
Else
' Do something here if the subscription does not exist.
Throw New ApplicationException(String.Format( _
"A subscription to '{0}' does not exists on {1}", _
publicationName, subscriberName))
End If
Catch ex As Exception
' Do appropriate error handling here.
Throw New ApplicationException("The subscription could not be synchronized.", ex)
Finally
conn.Disconnect()
End Try
Hinweise
Verwenden Sie das TransSynchronizationAgent von der Eigenschaft SynchronizationAgent zurückgegebene Objekt, um den Verteilungs-Agent synchron zu starten.
Wenn das Pull-Abonnement mit dem Wert für falseCreateSyncAgentByDefaulterstellt wird, wird standardmäßig kein Verteilungs-Agent-Job für das Abonnement erstellt und ein Aufruf SynchronizeWithJob verursacht eine Ausnahme.
Ruf die Methode StopSynchronizationJob auf, um den Job zu stoppen, falls er gerade läuft.
Der Job kann nicht starten, wenn der Microsoft SQL Server-Agent Service nicht läuft. Wenn kein Snapshot generiert wird, kann das Ausführen des Agent-Jobs das Abonnement nicht synchronisieren.
Wenn Sie auf dieser Instanz von TransPullSubscriptionzusätzliche Eigenschaften gesetzt haben, rufen CommitPropertyChanges Sie vor dem Aufruf auf.SynchronizeWithJob
Die Methode SynchronizeWithJob kann nur von Mitgliedern der Sysadmin-Fixed-Server-Rolle beim Subscriber oder von Mitgliedern der db_owner Fixed-Datenbank-Rolle in der Abonnement-Datenbank aufgerufen werden.