private void buttonSunc_Click(object sender, System.EventArgs e) {
SqlCeReplication repl = null;
if(System.IO.File.Exists("\\My Documents\\jtdb.sdf")){
System.IO.File.Delete("\\My Documents\\jtdb.sdf");
}
try {
// Set the Replication object.
repl = new SqlCeReplication();
repl.InternetUrl = "
http://xxx/pda/sscesa20.dll"; repl.InternetLogin = "";
repl.InternetPassword = "";
repl.Publisher = "xxx\\PDASYS2";
repl.PublisherDatabase = "JTDB";
repl.PublisherLogin = "pda";
repl.PublisherPassword = "xxxx";
repl.Publication = "JTDB";
repl.SubscriberConnectionString = "Provider=Microsoft.SqlCeSERVER.OLEDB.CE.2.0;Data Source=\\My Documents\\jtdb.sdf";
repl.Subscriber = "JTDB";
// Create the Local SSCE Database subscription.
repl.AddSubscription(AddOption.CreateDatabase);
// Synchronize to the instance of SqlCe Server 2000 to populate the Subscription.
repl.Synchronize();
MessageBox.Show("Sync ok!");
}
catch(SqlCeException ex) {
// Use your own error handling routine to show error information.
MessageBox.Show(ex.Message);
}
finally {
// Dispose of the Replication object.
repl.Dispose();
}