AddSubscription Method

Replication Programming

Replication Programming

AddSubscription Method

The AddSubscription method adds a new or existing subscription based on the specified control properties.

Applies To

SQLDistribution Object

SQLMerge Object

Syntax

object.AddSubscription DBAddOption, SubscriptionHost

Part Description
object Expression that evaluates to an object in the Applies To list.
DBAddOption Option to add; use a value from DBADDOPTION.
SubscriptionHost Subscription host; use a value from SUBSCRIPTION_HOST.
Remarks

Push subscriptions are not currently supported by this method.

If DBAddOption is set to ATTACH_DATABASE and SubscriberDatasourceType is set to SQL_SERVER, AddSubscription can work only with single-file databases. Use the SubscriberDatabasePath property to specify the name and path of the .mdf file to attach.

If DBAddOption is ATTACH_SUBSCRIPTION, use SubscriberDatabasePath to specify the name and path of the Microsoft Subscription File (.msf). This file can be created with the CopySubscription method.

AddSubscription also supports creating a new Subscriber database, creating a new subscription for an existing database, and registering an existing subscription with Windows Synchronization Manager.

In Microsoft® Visual Basic®, AddSubscription is a Sub method and does not return a value.

Prototype C/C++

HRESULT AddSubscription(
    DBADDOPTION DBAddOption,
    SUBSCRIPTION_HOST SubscriptionHost);

Return code Description
S_OK Method succeeded.
E_FAIL General failure occurred. Check error records for detailed information.
REPLX_E_DBEXISTS Specified database already exists.
REPLX_E_DBNOTFOUND Specified database does not exist.
REPLX_E_SUBEXISTS Specified subscription already exists.
REPLX_E_RETRYFAILURE Failure occurred that might require retrying the last operation.

See Also

CopySubscription Method

DropSubscription Method

SubscriberDatasourceType Property

SubscriberDatabasePath Property