SqlCeReplication.SaveProperties Method

Retrieves all of the values stored in the Replication class properties for the current subscription and stores them in a system table.

Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)

Syntax

'Declaration
Public Sub SaveProperties
'Usage
Dim instance As SqlCeReplication

instance.SaveProperties
public void SaveProperties ()
public:
void SaveProperties ()
public void SaveProperties ()
public function SaveProperties ()

Remarks

A subscription must be successfully created prior to saving the synchronization properties; all required parameters to run the synchronization must be supplied for call to SaveProperties to succeed. If non-required parameters are omitted when saving the synchronization properties, they will be set to their default values, even if saved synchronization properties already exist. To avoid properties being overwritten, a user should first retrieve the synchronization properties by calling LoadProperties, change the particular properties, and then re-save the synchronization properties.

When SaveProperties is called, the values for the password properties are stored in the database. These values are automatically encrypted with the unique device hardware key. Therefore, if you create a subscription profile on one device (or a server), and then copy the database to a new device, LoadProperties will fail to retrieve the password from the profile. You can provide the correct password manually and then call SaveProperties again to persist the profile on the new device.

Example

The following example shows how to use the SaveProperties method.

Dim repl As SqlCeReplication = Nothing

Try
    ' Create SqlCeReplication instance
    '
    repl = New SqlCeReplication()
    repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa30.dll"
    repl.InternetLogin = "MyInternetLogin"
    repl.InternetPassword = "<password>"
    repl.Publisher = "MyPublisher"
    repl.PublisherDatabase = "MyPublisherDatabase"
    repl.PublisherLogin = "MyPublisherLogin"
    repl.PublisherPassword = "<password>"
    repl.Publication = "MyPublication"
    repl.Subscriber = "MySubscriber"
    repl.SubscriberConnectionString = "Data Source=MyDatabase.sdf"

    ' Store all the properties in the database
    '
    repl.SaveProperties()

    ' In the future all you need to do is load the properties
    '
    repl = New SqlCeReplication()
    repl.SubscriberConnectionString = "Data Source='Test.sdf'; Pwd='<password>'"
    repl.LoadProperties()

    ' Now the SqlCeReplication instance is ready to sync
    '
    repl.Synchronize()

Catch
    ' Handle errors here
Finally
    ' Dispose the repl object
    '
    repl.Dispose()
End Try
SqlCeReplication repl = null;

try
{
    // Create SqlCeReplication instance
    //
    repl = new SqlCeReplication();
    repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa30.dll";
    repl.InternetLogin = "MyInternetLogin";
    repl.InternetPassword = "<password>";
    repl.Publisher = "MyPublisher";
    repl.PublisherDatabase = "MyPublisherDatabase";
    repl.PublisherLogin = "MyPublisherLogin";
    repl.PublisherPassword = "<password>";
    repl.Publication = "MyPublication";
    repl.Subscriber = "MySubscriber";
    repl.SubscriberConnectionString = "Data Source=MyDatabase.sdf";

    // Store all the properties in the database
    //
    repl.SaveProperties();

    // In the future all you need to do is load the properties
    //
    repl = new SqlCeReplication();
    repl.SubscriberConnectionString = "Data Source='Test.sdf'; Pwd='<password>'";
    repl.LoadProperties();

    // Now the SqlCeReplication instance is ready to sync
    //
    repl.Synchronize();


catch (SqlCeException)
{
    // Handle errors here

finally
{
    // Dispose the repl object
    //
    repl.Dispose();

.NET Framework Security

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Platforms

Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows XP Professional x64 Edition, Windows XP SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

Version Information

.NET Compact Framework

Supported in: 2.0

See Also

Reference

SqlCeReplication Class
SqlCeReplication Members
System.Data.SqlServerCe Namespace