AddSubscription Method (Replication)

Applications call the AddSubscription method to create a new anonymous subscription to an existing Microsoft SQL Server publication. After calling the AddSubscription method, the application must call the Synchronize method to synchronize the new subscription to the publication.

Syntax

object.AddSubscription(DBADDOPTION)

Applies To

SQL Server Compact 3.5 (SQL Server Compact 3.5) Replication object

Generic Parameters

Parameter Description

DBADDOPTION

Specifies how to create the new subscription

DBADDOPTION Parameter

The DBADDOPTION specifies how to create the new subscription. This parameter determines whether a new SQL Server Compact 3.5 database is created or whether an existing database is used, according to the settings in the following table:

Constant Value Description

EXISTING_DATABASE

0

Assumes the SQL Server Compact 3.5 database is already created.

CREATE_DATABASE

1

Causes the SQL Server Compact 3.5 database to be created on the device (default).

The DBADDOPTION value EXISTING_DATABASE specifies that the database already exists, but contents need to be obtained from the Publisher. In this case, the AddSubscription and Synchronize method creates the SQL Server Compact 3.5 subscription and then download the database contents from the SQL Server Publisher.

Because a single SQL Server Compact 3.5 database can be a subscriber to multiple publications, special consideration must be given when using the EXISTING_DATABASE value. If the database already exists, and you are adding an additional subscription, you must specify the Publisher, Publication, and PublisherDatabase properties before calling the AddSubscription method.

The DBADDOPTION value CREATE_DATABASE specifies that the SQL Server Compact 3.5 database must first be created, and then the subscription contents are obtained from the Publisher. In this case, the AddSubscription and Synchronize method creates the SQL Server Compact 3.5 database and subscription and download the database contents from the SQL Server Publisher.

Prototype

HRESULT AddSubscription(DBADDOPTION DBAddOption);

Returns

Return code Description

S_OK

Method succeeded.

Any FAILED(HRESULT)

Check the SSCEErrors collection for detailed error information.

Remarks

Before a SQL Server Compact 3.5 application can subscribe to a publication and replicate data, a database administrator must first configure SQL Server to support merge replication and create a SQL Server publication which is enabled for SQL Server Compact 3.5 subscriptions.

See Also

Reference

Publisher Property (Replication)
Publication Property (Replication)
PublisherDatabase Property (Replication)

Other Resources

Replication Object Methods

Help and Information

Getting Assistance (SQL Server Compact 3.5 Service Pack 1)