MergePullSubscription.Reinitialize Method
Marks the merge pull subscription for reinitialization.
Spazio dei nomi: Microsoft.SqlServer.Replication
Assembly : Microsoft.SqlServer.Rmo (in microsoft.sqlserver.rmo.dll)
Sintassi
'Dichiarazione
Public Sub Reinitialize ( _
uploadFirst As Boolean _
)
public void Reinitialize (
bool uploadFirst
)
public:
void Reinitialize (
bool uploadFirst
)
public void Reinitialize (
boolean uploadFirst
)
public function Reinitialize (
uploadFirst : boolean
)
Parametri
- uploadFirst
A Boolean value that specifies whether to upload all changes from the Subscriber before reapplying the snapshot to reinitialize the subscription. If true, the changes are uploaded before applying the snapshot. If false, the changes are not uploaded.
Osservazioni
After calling the Reinitialize method, you must start synchronization to reinitialize the subscription. For more information, see How to: Reinitialize a Subscription (RMO Programming).
The Reinitialize method can only be called by members of sysadmin fixed server role at the Subscriber or by members of the db_owner fixed database role on the subscription database.
Calling Reinitialize is equivalent to executing sp_reinitmergepullsubscription.
Set the uploadFirst parameter to false when working with instance of Microsoft SQL Server 7.0; otherwise an exception is thrown.
The Reinitialize method is available with Microsoft SQL Server 2000 and Microsoft SQL Server 2005.
This namespace, class, or member is supported only in version 2.0 of the Microsoft .NET Framework.
Esempio
// Define server, publication, and database names.
String subscriberName = subscriberInstance;
String publisherName = publisherInstance;
String publicationName = "AdvWorksSalesOrdersMerge";
String publicationDbName = "AdventureWorks";
String subscriptionDbName = "AdventureWorksReplica";
// 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 = "AdventureWorks"
Dim subscriptionDbName As String = "AdventureWorksReplica"
' 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
Thread Safety
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Piattaforme
Piattaforme di sviluppo
Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.
Piattaforme di destinazione
Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.
Vedere anche
Riferimento
MergePullSubscription Class
MergePullSubscription Members
Microsoft.SqlServer.Replication Namespace