共用方式為


SqlCeReplication.SqlCeReplication(String, String, String, String, String, String, String, String, String, String) Constructor

Initializes a new instance of the SqlCeReplication object and sets the properties for connecting to a publication.

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

Syntax

'Declaration
Public Sub New ( _
    internetUrl As String, _
    internetLogin As String, _
    internetPassword As String, _
    publisher As String, _
    publisherDatabase As String, _
    publisherLogin As String, _
    publisherPassword As String, _
    publication As String, _
    subscriber As String, _
    subscriberConnectionString As String _
)
'Usage
Dim internetUrl As String
Dim internetLogin As String
Dim internetPassword As String
Dim publisher As String
Dim publisherDatabase As String
Dim publisherLogin As String
Dim publisherPassword As String
Dim publication As String
Dim subscriber As String
Dim subscriberConnectionString As String

Dim instance As New SqlCeReplication(internetUrl, internetLogin, internetPassword, publisher, publisherDatabase, publisherLogin, publisherPassword, publication, subscriber, subscriberConnectionString)
public SqlCeReplication (
    string internetUrl,
    string internetLogin,
    string internetPassword,
    string publisher,
    string publisherDatabase,
    string publisherLogin,
    string publisherPassword,
    string publication,
    string subscriber,
    string subscriberConnectionString
)
public:
SqlCeReplication (
    String^ internetUrl, 
    String^ internetLogin, 
    String^ internetPassword, 
    String^ publisher, 
    String^ publisherDatabase, 
    String^ publisherLogin, 
    String^ publisherPassword, 
    String^ publication, 
    String^ subscriber, 
    String^ subscriberConnectionString
)
public SqlCeReplication (
    String internetUrl, 
    String internetLogin, 
    String internetPassword, 
    String publisher, 
    String publisherDatabase, 
    String publisherLogin, 
    String publisherPassword, 
    String publication, 
    String subscriber, 
    String subscriberConnectionString
)
public function SqlCeReplication (
    internetUrl : String, 
    internetLogin : String, 
    internetPassword : String, 
    publisher : String, 
    publisherDatabase : String, 
    publisherLogin : String, 
    publisherPassword : String, 
    publication : String, 
    subscriber : String, 
    subscriberConnectionString : String
)
Not applicable.

Parameters

  • internetUrl
    The URL used to connect to the SQL Server Compact Edition Server Agent.
  • internetLogin
    The login name used when connecting to the SQL Server Compact Edition Server Agent.
  • internetPassword
    The password used when connecting to the SQL Server Compact Edition Server Agent.
  • publisher
    The name of the Publisher.
  • publisherDatabase
    The name of the publication database.
  • publisherLogin
    The login name used when connecting to the Publisher.
  • publisherPassword
    The login password used when connecting to the Publisher.
  • publication
    The publication name that has been enabled for anonymous merge subscriptions.
  • subscriber
    The name of the Subscriber.
  • subscriberConnectionString
    The OLE DB connection string for the SQL Server Compact Edition database on the Windows Mobile-based device.

Example

Dim repl As SqlCeReplication = Nothing

Try
    ' Instantiate and configure SqlCeReplication object
    '
    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"

    ' 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
    //
    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";

    // 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();
}

Platforms

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

.NET Compact Framework

Supported in: 2.0, 1.0

See Also

Reference

SqlCeReplication Class
SqlCeReplication Members
System.Data.SqlServerCe Namespace