EnableTransSubscription Method (SQL-DMO)

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

Applies To

ReplicationDatabase Object

Syntax

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

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 transactional or snapshot 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 transactional replication Subscriber visibility 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
SQLDMOTranSubscriber_Default 0 SQLDMOTranSubscriber_
ReadOnly
SQLDMOTranSubscriber_Max 1 SQLDMOTranSubscriber_
Synchronous
SQLDMOTranSubscriber_Min 0 SQLDMOTranSubscriber_
ReadOnly
SQLDMOTranSubscriber_ReadOnly 0 Subscriber update to any publication article affects only the image maintained at the Subscriber
SQLDMOTranSubscriber_
Synchronous
1 Subscriber update to a publication article is applied in a distributed transaction, updating the Publisher-maintained image for article data or failing entirely
SQLDMOTranSubscriber_Unknown 256 Bad or invalid value

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 transactional or snapshot replication publication

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

For more information on creating pull subscriptions to transactional and snapshot replication publications by using SQL-DMO, see TransPullSubscription Object.

Prototype (C/C++)

HRESULT EnableTransSubscription(SQLDMO_LPCSTR Subscriber, SQLDMO_LPCSTR SubscriptionDatabase,
SQLDMO_LPCSTR Publication,
SQLDMO_SUBSCRIPTION_TYPE SubscriptionType = SQLDMOSubscription_Pull
SQLDMO_SUBSYNC_TYPE SyncType = SQLDMOSubSync_Auto,
SQLDMO_TRANSUBSCRIBER_TYPE SubscriberType =
SQLDMOTranSubscriber_ReadOnly);

  


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