EnableTransSubscription Method
未來的 Microsoft SQL Server 版本將移除這項功能。請避免在新的開發工作中使用這項功能,並規劃修改目前使用這項功能的應用程式。
The EnableTransSubscription method enables a Subscriber-originated (pull) subscription at the Publisher and Distributor.
語法
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 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. |
備註
Creating a pull subscription using SQL Distributed Management Objects (SQL-DMO) is a two-step process. The application must define the subscription at the Subscriber, and then separately enable the subscription at the Publisher and Distributor.
To create a pull subscription to a transactional or snapshot replication publication
Establish SQLServer object connection to the Subscriber.
Create and populate a TransPullSubscription object.
Add the TransPullSubscription object to the TransPullSubscriptions collection of the appropriate ReplicationDatabase object.
Establish SQLServer object connection to the Publisher.
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.