EnableMergeSubscription Method (SQL-DMO)

The EnableMergeSubscription method enables a Subscriber-originated (pull) subscription at the Publisher and Distributor.

Applies To

ReplicationDatabase Object

Syntax

object.EnableMergeSubscription( Subscriber, SubscriptionDatabase,
Publication , [ SubscriptionType ] , [ SyncType ] , [ SubscriberType ] ,
[ SubscriptionPriority ] )

Part Description
object Expression that evaluates to an object in the Applies To list.
Subscriber String identifying the Subscriber by name.
SubscriptionDatabase String identifying a Microsoft® SQL Server™ database existing on the Subscriber and used for replicated article storage.
Publication String identifying an existing merge replication publication maintained on the referenced database.
SubscriptionType Long integer specifying a subscription direction. Must evaluate to SQLDMOSubscription_Pull.
SyncType Long integer specifying a method for synchronization as described in Settings.
SubscriberType Long integer specifying merge Subscriber visibility as described in Settings.
SubscriptionPriority Float specifying relative priority for conflict resolution as described in Settings.

Settings

Set the SyncType argument by using these values.

Constant Value Description
SQLDMOSubSync_Auto 1 Subscription agent will synchronize the subscription automatically.
SQLDMOSubSync_Default 1 SQLDMOSubSync_Auto.
SQLDMOSubSync_Max 2 SQLDMOSubSync_None.
SQLDMOSubSync_Min 1 SQLDMOSubSync_Auto.
SQLDMOSubSync_None 2 Subscription agent will not attempt publication synchronization. User interaction necessary to ensure synchronization.

Set the SubscriberType argument by using these values.

Constant Value Description
SQLDMOMergeSubscriber_
Anonymous
3 Anonymous subscription
SQLDMOMergeSubscriber_Default 2 SQLDMOMergeSubscriber_
Local
SQLDMOMergeSubscriber_Global 1 Global subscription
SQLDMOMergeSubscriber_Local 2 Local subscription

When setting the SubscriptionPriority argument, use the value specified in SubscriberType to determine applicable priorities.

SubscriberType SubscriptionPriority
SQLDMOMergeSubscriber_Anonymous or
SQLDMOMergeSubscriber_Local
Must be 0.0
SQLDMOMergeSubscriber_Global Value from 0.0 through 100.0

Remarks

Creating a pull subscription by using SQL-DMO is a two-step process. The application must define the subscription at the Subscriber, then, separately, enable the subscription at the Publisher and Distributor.

To create a pull subscription to a merge replication publication

  1. Establish a SQLServer object connection to the Subscriber.
  2. Create and populate a MergePullSubscription object.
  3. Add the MergePullSubscription object to the MergePullSubscriptions collection of the appropriate ReplicationDatabase object.
  4. Establish a SQLServer object connection to the Publisher.
  5. Use the EnableMergeSubscription method of the appropriate ReplicationDatabase object indicating the subscription created in Step 3.

For more information on creating pull subscriptions to merge replication publications by using SQL-DMO, see MergePullSubscription Object.

Prototype (C/C++)

HRESULT EnableMergeSubscription(SQLDMO_LPCSTR Subscriber, SQLDMO_LPCSTR SubscriptionDatabase,
SQLDMO_LPCSTR Publication,
SQLDMO_SUBSCRIPTION_TYPE SubscriptionType = SQLDMOSubscription_Pull
SQLDMO_SUBSYNC_TYPE SyncType = SQLDMOSubSync_Auto,
SQLDMO_MERGESUBSCRIBER_TYPE SubscriberType =
SQLDMOMergeSubscriber_Local,
float SubscriptionPriority  = 0.0));

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.