ReplicationDatabase ReplicationDatabase ReplicationDatabase Constructors

정의

오버로드

ReplicationDatabase() ReplicationDatabase() ReplicationDatabase()

ReplicationDatabase 클래스의 새 인스턴스를 초기화합니다. Initializes a new instance of the ReplicationDatabase class.

ReplicationDatabase(String, ServerConnection) ReplicationDatabase(String, ServerConnection) ReplicationDatabase(String, ServerConnection)

데이터베이스가 있는 서버에 대한 연결을 제공하고 지정된 데이터베이스 이름을 사용하여 ReplicationDatabase 클래스의 새 인스턴스를 초기화합니다. Initializes a new instance of the ReplicationDatabase class with the specified database name, providing a connection to the server on which the database exists.

ReplicationDatabase() ReplicationDatabase() ReplicationDatabase()

ReplicationDatabase 클래스의 새 인스턴스를 초기화합니다. Initializes a new instance of the ReplicationDatabase class.

public:
 ReplicationDatabase();
public ReplicationDatabase ();
Public Sub New ()

설명

기본 생성자는 모든 필드를 기본값으로 초기화합니다.The default constructor initializes any fields to their default values.

ReplicationDatabase(String, ServerConnection) ReplicationDatabase(String, ServerConnection) ReplicationDatabase(String, ServerConnection)

데이터베이스가 있는 서버에 대한 연결을 제공하고 지정된 데이터베이스 이름을 사용하여 ReplicationDatabase 클래스의 새 인스턴스를 초기화합니다. Initializes a new instance of the ReplicationDatabase class with the specified database name, providing a connection to the server on which the database exists.

public:
 ReplicationDatabase(System::String ^ name, Microsoft::SqlServer::Management::Common::ServerConnection ^ connectionContext);
public ReplicationDatabase (string name, Microsoft.SqlServer.Management.Common.ServerConnection connectionContext);
Public Sub New (name As String, connectionContext As ServerConnection)
매개 변수
name
String String String

복제 데이터베이스의 이름을 지정하는 String 값입니다. A String value that specifies the name of the replication database.

connectionContext
Microsoft.SqlServer.Management.Common.ServerConnection Microsoft.SqlServer.Management.Common.ServerConnection Microsoft.SqlServer.Management.Common.ServerConnection

A Microsoft.SqlServer.Management.Common.ServerConnection 개체의 SQL Server 인스턴스에 대 한 연결을 설정 하는 데 사용 되는 연결 컨텍스트를 지정 하는 값입니다. A Microsoft.SqlServer.Management.Common.ServerConnection object value that specifies the connection context that is used to establish a connection to the instance of SQL Server.

예제

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

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 AdventureWorks2012 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();
}
' Set the server and database names
Dim distributionDbName As String = "distribution"
Dim publisherName As String = publisherInstance
Dim publicationDbName As String = "AdventureWorks2012"

Dim distributionDb As DistributionDatabase
Dim distributor As ReplicationServer
Dim publisher As DistributionPublisher
Dim publicationDb As ReplicationDatabase

' Create a connection to the server using Windows Authentication.
Dim conn As ServerConnection = 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((CType(Nothing, String)), 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 AdventureWorks2012 as a publication database.
    publicationDb = New ReplicationDatabase(publicationDbName, conn)

    publicationDb.EnabledTransPublishing = True
    publicationDb.EnabledMergePublishing = True

Catch ex As Exception
    ' Implement appropriate error handling here.
    Throw New ApplicationException("An error occured when installing distribution and publishing.", ex)

Finally
    conn.Disconnect()

End Try
추가 정보

적용 대상