SubscriberConnectionString Property

Specifies the connection string to the database.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

Syntax

'Declaration
Public Property SubscriberConnectionString As String
    Get
    Set
'Usage
Dim instance As SqlCeReplication
Dim value As String

value = instance.SubscriberConnectionString

instance.SubscriberConnectionString = value
public string SubscriberConnectionString { get; set; }
public:
property String^ SubscriberConnectionString {
    String^ get ();
    void set (String^ value);
}
member SubscriberConnectionString : string with get, set
function get SubscriberConnectionString () : String
function set SubscriberConnectionString (value : String)

Property Value

Type: System. . :: . .String
The connection string to the database.

Remarks

This property supports all of the ConnectionString properties, except for "persist security info".

Locale Identifier values are supported when creating a new database using the AddSubscription method. Use the Unique LCID for the value of Locale Identifier. To find a list of Unique LCID values, see the Collate topic in the SQL Reference section of the Books Online. You must ensure that the locale is supported on the device on which the database is being created.

When specifying the Data Source property of the [SubscriberConnectionString], you should include the full path to the database file rather than a relative path.

Examples

The following example sets the SubscriberConnectionString property of the SqlCeReplication object.

Dim repl As SqlCeReplication = Nothing

Try
    ' Instantiate and configure SqlCeReplication object
    '
    'NOTE: when possible, prompt users to enter security 
    'credentials at runtime. If you store credentials in a file, 
    'you must secure the file to prevent unauthorized access.
    '
    repl = New SqlCeReplication()
    repl.InternetUrl = "https://www.adventure-works.com/sqlce/sqlcesa35.dll"
    repl.InternetLogin = "MyInternetLogin"
    repl.InternetPassword = "<enterStrongPassword>"
    repl.Publisher = "MyPublisher"
    repl.PublisherDatabase = "MyPublisherDatabase"
    repl.PublisherLogin = "MyPublisherLogin"
    repl.PublisherPassword = "<enterStrongPassword>"
    repl.Publication = "MyPublication"
    repl.Subscriber = "MySubscriber"
    repl.SubscriberConnectionString = "Data Source=MyDatabase.sdf"

    ' Create the local SQL Mobile Database subscription
    '
    repl.AddSubscription(AddOption.CreateDatabase)

    ' Synchronize to the SQL Server to populate the Subscription 
    '
    repl.Synchronize()
Catch
    ' Handle errors here
    '
Finally
    ' Dispose the repl object
    '
    repl.Dispose()
End Try
SqlCeReplication repl = null;

try
{
    // Instantiate and configure SqlCeReplication object
    //
    //NOTE: when possible, prompt users to enter security 
    //credentials at runtime. If you store credentials in a file, 
    //you must secure the file to prevent unauthorized access.
    //
    repl = new SqlCeReplication();
    repl.InternetUrl = "https://www.adventure-works.com/sqlce/sqlcesa35.dll";
    repl.InternetLogin = "MyInternetLogin";
    repl.InternetPassword = "<enterStrongPassword>";
    repl.Publisher = "MyPublisher";
    repl.PublisherDatabase = "MyPublisherDatabase";
    repl.PublisherLogin = "MyPublisherLogin";
    repl.PublisherPassword = "<enterStrongPassword>";
    repl.Publication = "MyPublication";
    repl.Subscriber = "MySubscriber";
    repl.SubscriberConnectionString = "Data Source=MyDatabase.sdf";

    // Create a local SQL Mobile Database subscription
    //
    repl.AddSubscription(AddOption.CreateDatabase);

    // Synchronize to the SQL Server database
    //
    repl.Synchronize();
}
catch (SqlCeException)
{
    // Handle errors here
    //
}
finally
{
    // Dispose the repl object
    //
    repl.Dispose();
}

See Also

Reference

SqlCeReplication Class

SqlCeReplication Members

System.Data.SqlServerCe Namespace