AddSubscription Method (Replication ActiveX)

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

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 (Replication ActiveX).

SubscriptionHost

Subscription host; use a value from SUBSCRIPTION_HOST (Replication ActiveX).

Return Value

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.

Applies To

SQLDistribution Object (Replication ActiveX)

SQLMerge Object (Replication ActiveX)

Remarks

Push subscriptions are not currently supported by this method.

The Initialize Method (Replication ActiveX) should not be called prior to using AddSubscription.

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

If DBAddOption is ATTACH_SUBSCRIPTION, use SubscriberDatabasePath Property (Replication ActiveX) to specify the name and path of the Microsoft Subscription File (.msf). This file can be created with the CopySubscription Method (Replication ActiveX) 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);

See Also

Reference

CopySubscription Method (Replication ActiveX)
DropSubscription Method (Replication ActiveX)
SubscriberDatasourceType Property (Replication ActiveX)
SubscriberDatabasePath Property (Replication ActiveX)

Help and Information

Getting SQL Server 2005 Assistance