MergePullSubscription.Reinitialize(Boolean) 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.
Markiert das Merge-Pull-Abonnement zur Neuinitialisierung.
public:
void Reinitialize(bool uploadFirst);
public void Reinitialize(bool uploadFirst);
member this.Reinitialize : bool -> unit
Public Sub Reinitialize (uploadFirst As Boolean)
Parameter
- uploadFirst
- Boolean
Ein Boolean Wert, der angibt, ob alle Änderungen vom Abonnenten hochgeladen werden sollen, bevor der Snapshot erneut angewendet wird, um das Abonnement neu zu initialisieren. Wenn zutreffend, werden die Änderungen hochgeladen, bevor der Snapshot angewendet wird. Falls falsch, werden die Änderungen nicht hochgeladen.
Beispiele
// Define server, publication, and database names.
String subscriberName = subscriberInstance;
String publisherName = publisherInstance;
String publicationName = "AdvWorksSalesOrdersMerge";
String publicationDbName = "AdventureWorks2012";
String subscriptionDbName = "AdventureWorks2012Replica";
// Create a connection to the Subscriber.
ServerConnection conn = new ServerConnection(subscriberName);
MergePullSubscription subscription;
try
{
// Connect to the Subscriber.
conn.Connect();
// Define subscription properties.
subscription = new MergePullSubscription();
subscription.ConnectionContext = conn;
subscription.DatabaseName = subscriptionDbName;
subscription.PublisherName = publisherName;
subscription.PublicationDBName = publicationDbName;
subscription.PublicationName = publicationName;
// If the pull subscription and the job exists, mark the subscription
// for reinitialization after upload and start the agent job.
if (subscription.LoadProperties() && subscription.AgentJobId != null)
{
subscription.Reinitialize(true);
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 = "AdvWorksSalesOrdersMerge"
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 MergePullSubscription
Try
' Connect to the Subscriber.
conn.Connect()
' Define subscription properties.
subscription = New MergePullSubscription()
subscription.ConnectionContext = conn
subscription.DatabaseName = subscriptionDbName
subscription.PublisherName = publisherName
subscription.PublicationDBName = publicationDbName
subscription.PublicationName = publicationName
' If the pull subscription and the job exists, mark the subscription
' for reinitialization after upload and start the agent job.
If subscription.LoadProperties() And (Not subscription.AgentJobId Is Nothing) Then
subscription.Reinitialize(True)
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
Nachdem Sie die Methode Reinitialize aufgerufen haben, müssen Sie mit der Synchronisation beginnen, um das Abonnement neu zu initialisieren. Weitere Informationen finden Sie unter How to: Reinitialize a Subscription (RMO Programming).
Die Methode Reinitialize kann nur von Mitgliedern der Sysadmin-Fixed-Server-Rolle am Subscriber oder von Mitgliedern der db_owner Fixed-Datenbank-Rolle in der Abonnementdatenbank aufgerufen werden.
Das Anrufen Reinitialize ist äquivalent zum Ausführen sp_reinitmergepullsubscription.