An application uses the Replication object to reinitialize an existing Microsoft SQL Server subscription so that a new snapshot data is downloaded from the Publisher. This is especially useful when the Microsoft SQL Server Compact 3.5 subscription contains read-only data that is periodically updated at the Publisher.
An application reinitializes a subscription by creating the Replication object, setting the appropriate Replication object properties, and then calling the ReInitializeSubscription Method (Replication) method.
In Microsoft Visual C++ for Devices, your application must call the ReinitializeSubscription, Initialize Method (Replication), Run Method (Replication), and Terminate Method (Replication) in succession on a single instance of the Replication object. This is important because when the application calls ReinitializeSubscription, the existing replica is only marked for reinitialization. Only after the application calls Initialize, Run, and Terminate is the existing replica deleted and a new replica of the publication downloaded from the Publisher to the device. When you use managed code, only the ReinitializeSubscription method is used.
The examples in this topic show how to reinitialize a subscription.
Multiple Subscriptions and the ReinitializeSubscription Method
Because SQL Server Compact 3.5 supports synchronizing a single database with multiple publications, you must consider the effects of multiple subscriptions when reinitializing a subscription with the ReinitializeSubscription method.
If the database contains only one subscription, the ReinitializeSubscription method marks that subscription for reinitialization during the next synchronization.
If the database contains multiple subscriptions, you must set the Publisher, Publication, and PublisherDatabase properties to indicate which subscription will be reinitialized.
Any time an automatic resynchronization occurs, it is considered a separate synchronization to SQL Server. Therefore, SQL Server Replication Monitor will have a separate synchronization for each. On the SQL Server Compact 3.5 subscriber, the values of the PublisherChanges, SubscriberChanges, PublisherConflicts, and SubscriberConflicts properties of the SqlCeReplication class is summed up, and the total of all synchronizations is provided on the return of the last synchronization.