Freigeben über


ReplicationServer.InstallDistributor Method (String, DistributionDatabase)

Installs a Distributor on the currently connected instance of Microsoft SQL Server.

Namespace: Microsoft.SqlServer.Replication
Assembly : Microsoft.SqlServer.Rmo (in microsoft.sqlserver.rmo.dll)

Syntax

'Declaration
Public Sub InstallDistributor ( _
    password As String, _
    distributionDB As DistributionDatabase _
)
public void InstallDistributor (
    string password,
    DistributionDatabase distributionDB
)
public:
void InstallDistributor (
    String^ password, 
    DistributionDatabase^ distributionDB
)
public void InstallDistributor (
    String password, 
    DistributionDatabase distributionDB
)
public function InstallDistributor (
    password : String, 
    distributionDB : DistributionDatabase
)

Parameter

  • password
    Is the password of the distributor_admin login used to access the Distributor.

    ms151521.security(de-de,SQL.90).gifSicherheitshinweis:
    When possible, prompt users to enter security credentials at run time. If you must store credentials, use the cryptographic services provided by the Windows .NET Framework.
  • distributionDB
    A DistributionDatabase object representing the distribution database used by the Distributor.

Ausnahmen

Ausnahmetyp Bedingung
ApplicationException

When distribution is already installed on the server.

ArgumentException

When distributionDB is null, or when password exceeds 128 bytes or contains null characters.

Hinweise

You must specify a strong password for password when the Distributor has remote Publishers. If password is set to null, a random password is generated, and you must call ChangeDistributorPassword to reset the password when the first remote Publisher is registered at the Distributor.

This method overload must be called at the Distributor before calling InstallDistributor from a remote server.

The InstallDistributor method can only be called by a member of the sysadmin fixed server role.

The InstallDistributor method is equivalent to the sp_adddistributor (Transact-SQL) stored procedure.

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

Beispiel

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

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

Threadsicherheit

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.

Plattformen

Entwicklungsplattformen

Eine Liste der unterstützten Plattformen finden Sie unterHardware- und Softwareanforderungen für die Installation von SQL Server 2005.

Zielplattforme

Eine Liste der unterstützten Plattformen finden Sie unterHardware- und Softwareanforderungen für die Installation von SQL Server 2005.

Siehe auch

Verweis

ReplicationServer Class
ReplicationServer Members
Microsoft.SqlServer.Replication Namespace

Andere Ressourcen

How to: Configure Publishing and Distribution (RMO Programming)