Поделиться через


Метод InstallDistributor

Installs a Distributor.

Этот элемент перегружен. Чтобы получить полные сведения об этом элементе (синтаксисе, использовании и примерах использования), щелкните его имя в списке перегрузок.

Список перегрузок

  Имя Описание
Открытый метод InstallDistributor(SecureString, DistributionDatabase) Installs a Distributor on the currently connected instance of Microsoft SQL Server, where the password is specified using a SecureString object.
Открытый метод InstallDistributor(String, DistributionDatabase) Installs a Distributor on the currently connected instance of Microsoft SQL Server.
Открытый метод InstallDistributor(String, SecureString) Registers a remote Distributor, where the password is specified using a SecureString object.
Открытый метод InstallDistributor(String, String) Registers a remote Distributor.

В начало

Замечания

This namespace, class, or member is supported only in version 2.0 of the .NET Framework.

Примеры

          // Set the server and database names
            string distributionDbName = "distribution";
            string publisherName = publisherInstance;
            string publicationDbName = "AdventureWorks2008R2";

            DistributionDatabase distributionDb;
            ReplicationServer distributor;
            DistributionPublisher publisher;
            ReplicationDatabase publicationDb;

            // Create a connection to the server using Windows Authentication.
            ServerConnection conn = new ServerConnection(publisherName);

            try
            {
                // Connect to the server acting as the Distributor 
                // and local Publisher.
                conn.Connect();

                // Define the distribution database at the Distributor,
                // but do not create it now.
                distributionDb = new DistributionDatabase(distributionDbName, conn);
                distributionDb.MaxDistributionRetention = 96;
                distributionDb.HistoryRetention = 120;

                // Set the Distributor properties and install the Distributor.
                // This also creates the specified distribution database.
                distributor = new ReplicationServer(conn);
                distributor.InstallDistributor((string)null, distributionDb);

                // Set the Publisher properties and install the Publisher.
                publisher = new DistributionPublisher(publisherName, conn);
                publisher.DistributionDatabase = distributionDb.Name;
                publisher.WorkingDirectory = @"\\" + publisherName + @"\repldata";
                publisher.PublisherSecurity.WindowsAuthentication = true;
                publisher.Create();

                // Enable AdventureWorks as a publication database.
                publicationDb = new ReplicationDatabase(publicationDbName, conn);

                publicationDb.EnabledTransPublishing = true;
                publicationDb.EnabledMergePublishing = true;
            }
            catch (Exception ex)
            {
                // Implement appropriate error handling here.
                throw new ApplicationException("An error occured when installing distribution and publishing.", ex);
            }
            finally
            {
                conn.Disconnect();
            }