DistributionDatabase 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示分发服务器上的分发数据库。
public ref class DistributionDatabase sealed : Microsoft::SqlServer::Replication::ReplicationObject
public sealed class DistributionDatabase : Microsoft.SqlServer.Replication.ReplicationObject
type DistributionDatabase = class
inherit ReplicationObject
Public NotInheritable Class DistributionDatabase
Inherits ReplicationObject
- 继承
示例
// 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
注解
线程安全性
Microsoft Visual Basic) 此类型成员中的任何公共静态 Shared
(对于多线程操作都是安全的。 但不保证所有实例成员都是线程安全的。
构造函数
DistributionDatabase() |
创建 DistributionDatabase 类的新实例。 |
DistributionDatabase(String, ServerConnection) |
使用指定的数据库名称和与分发服务器的连接创建 DistributionDatabase 类的新实例。 |
属性
CachePropertyChanges |
获取或设置是缓存对复制属性所做的更改还是立即应用它们。 (继承自 ReplicationObject) |
ConnectionContext |
获取或设置与 Microsoft SQL Server 实例的连接。 (继承自 ReplicationObject) |
DataFile |
获取或设置分发数据库的数据文件的名称。 |
DataFileSize |
获取或设置分发数据库的主数据库文件的大小。 |
DataFolder |
获取或设置包含分发数据库的数据文件的目录的路径。 |
DistributionCleanupTaskName |
获取负责清理分发中的复制表的SQL Server 代理作业的名称。 |
DistributorSecurity |
获取用于连接到分发服务器以创建分发数据库的安全上下文。 |
HistoryCleanupTaskName |
获取负责清理复制历史记录表的SQL Server 代理作业的名称。 |
HistoryRetention |
获取或设置复制代理历史记录数据要保留的时间长度(以小时为单位)。 |
IsExistingObject |
获取服务器上是否存在该对象。 (继承自 ReplicationObject) |
LogFile |
获取或设置用于存储数据库事务日志记录的文件的名称。 |
LogFileSize |
获取或设置用于存储数据库事务日志记录的文件的大小。 |
LogFolder |
获取或设置存储数据库事务日志记录的文件所在的目录的路径。 |
MaxDistributionRetention |
获取或设置从分发数据库中删除事务前的最大保持期(以小时为单位)。 |
MinDistributionRetention |
获取或设置从分发数据库中删除事务前的最小保持期(以小时为单位)。 |
Name |
获取或设置分发数据库的名称。 |
QueueReaderAgentExists |
获取或设置是否已经为此分发数据库创建了队列读取器代理作业。 |
QueueReaderAgentName |
获取或设置为此分发数据库创建的队列读取器代理作业的名称。 |
QueueReaderAgentProcessSecurity |
获取用于运行队列读取器代理作业的代理进程安全上下文。 |
SqlServerName |
获取此 对象连接到的 Microsoft SQL Server 实例的名称。 (继承自 ReplicationObject) |
UserData |
获取或设置允许用户将他们自己的数据附加到该对象的对象属性。 (继承自 ReplicationObject) |