EnableTransSubscription Method

SQL-DMO

SQL-DMO

EnableTransSubscription Method

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 ] )

Parts

object

Expression that evaluates to an object in the Applies To list.

Subscriber

String that identifies the Subscriber by name.

SubscriptionDatabase

String that identifies a Microsoft® SQL Server™ 2000 database that exists on the subscriber and is used for replicated article storage.

Publication

String that identifies an existing transactional or snapshot replication publication maintained on the referenced database.

SubscriptionType

Long integer that specifies a subscription direction. Must evaluate to SQLDMOSubscription_Pull.

SyncType

Long integer that specifies a method for synchronization as described in Settings.

 SubscriberType

Long integer that specifies transactional replication Subscriber visibility as described in Settings.

Prototype (C/C++)

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

Settings

Set the SyncType argument using these SQLDMO_SUBSCRIPTION_TYPE values.

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

Set the SubscriberType argument using these SQLDMO_TRANSUBSCRIBER_TYPE values.

Constant Value Description
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.
SQLDMOTranSubscriber_Default 0 SQLDMOTranSubscriber_ReadOnly.
SQLDMOTranSubscriber_Failover 3 Transactional Immediate Updating Subscriber with capability to fail over to queued Subscriber.
SQLDMOTranSubscriber_Queued 2 Subscriber update to a publication article is applied as a queued transaction.
SQLDMOTranSubscriber_ReadOnly 0 Default. Subscriber update to any publication article affects only the image maintained at the Subscriber.
SQLDMOTranSubscriber_Unknown 256 Bad or invalid value.

Remarks

Creating a pull subscription 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 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 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 about creating pull subscriptions to transactional and snapshot replication publications using SQL-DMO, see TransPullSubscription Object.