/// <summary>
        ///		Removes a subscription from the local database.
        /// </summary>
        /// <param name="subscription"></param>
        public void Drop(Subscription subscription)
        {
            Guard.ArgumentNotNull(subscription, "subscription");

            lock (subscriptions)
            {
                if (!Subscriptions.Contains(subscription))
                {
                    throw new ArgumentException(Properties.Resources.NoSuchSubscription);
                }

                //
                // The subscription information isn't saved in the replication tables until the
                // subscription is synchronized.
                //
                if (subscription.HasBeenSynchronized)
                {
                    SqlCeReplication replication = new SqlCeReplication();
                    replication.SubscriberConnectionString = refDatabase.ConnectionString;
                    replication.Publication       = subscription.Publication;
                    replication.Publisher         = subscription.Publisher;
                    replication.PublisherDatabase = subscription.PublisherDatabase;

                    replication.DropSubscription(DropOption.LeaveDatabase);
                }

                string      sql         = @"DELETE FROM SubscriptionInfo WHERE SubscriptionInfoID=" + infoDatabase.BuildParameterName("ID");
                DbParameter idParameter = infoDatabase.CreateParameter("@ID", subscription.SubscriptionInfoId);
                infoDatabase.ExecuteNonQuery(sql, idParameter);

                subscriptions.Remove(subscription);
            }
        }
Example #2
0
        public static void DropPublication(string connectionString, string publicationLabel)
        {
            string[] vals                = publicationLabel.Split(':');
            string   publisher           = vals[0];
            string   publicationDatabase = vals[1];
            string   publication         = vals[2];

            using (SqlCeReplication repl = new SqlCeReplication())
            {
                repl.SubscriberConnectionString = connectionString;
                repl.Publisher         = publisher;
                repl.Publication       = publication;
                repl.PublisherDatabase = publicationDatabase;
                repl.LoadProperties();
                repl.DropSubscription(DropOption.LeaveDatabase);
            }
        }
Example #3
0
 public static void DropPublication(string connectionString, string publicationLabel)
 {
     string[] vals = publicationLabel.Split(':');
     string publisher = vals[0];
     string publicationDatabase = vals[1];
     string publication = vals[2];
     using (SqlCeReplication repl = new SqlCeReplication())
     {
         repl.SubscriberConnectionString = connectionString;
         repl.Publisher = publisher;
         repl.Publication = publication;
         repl.PublisherDatabase = publicationDatabase;
         repl.LoadProperties();
         repl.DropSubscription(DropOption.LeaveDatabase);
     }
 }