SqlCeReplication Class
Initializes a new instance of the SqlCeReplication object. For more information about replication, see the Books Online. For more information about merge replication with , see the Books Online.
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)
Syntax
'Declaration
Public NotInheritable Class SqlCeReplication _
Implements IDisposable
'Usage
Dim instance As SqlCeReplication
public sealed class SqlCeReplication : IDisposable
public ref class SqlCeReplication sealed : IDisposable
[<SealedAttribute>]
type SqlCeReplication =
class
interface IDisposable
end
public final class SqlCeReplication implements IDisposable
Remarks
is not currently optimized to serve as a database for Web sites. By default, connections from -connected applications are blocked in . is optimized for use as an embedded database within applications. Using as a database for Web sites requires support for multiple users and concurrent data changes. This can cause performance problems. Therefore, these scenarios are not supported. Other editions of , including and later versions, are optimized to serve as a database for Web sites.
can be used with in application scenarios where is used to create databases for synchronization scenarios. Use the following code to change the default behavior of to work within .
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true)
Examples
The following example shows how to synchronize data between a Subscriber and a Publisher. A SqlCeReplication object is created, numerous properties of the SqlCeReplication object are set, and then the Synchronize method is called.
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();
}
Inheritance Hierarchy
System. . :: . .Object
System.Data.SqlServerCe..::..SqlCeReplication
Thread Safety
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.