TransPullSubscription 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示对事务发布的请求订阅。
public ref class TransPullSubscription sealed : Microsoft::SqlServer::Replication::PullSubscription
public sealed class TransPullSubscription : Microsoft.SqlServer.Replication.PullSubscription
type TransPullSubscription = class
inherit PullSubscription
Public NotInheritable Class TransPullSubscription
Inherits PullSubscription
- 继承
示例
// Define the Publisher, publication, and databases.
string publicationName = "AdvWorksProductTran";
string publisherName = publisherInstance;
string subscriberName = subscriberInstance;
string subscriptionDbName = "AdventureWorks2012Replica";
string publicationDbName = "AdventureWorks2012";
//Create connections to the Publisher and Subscriber.
ServerConnection subscriberConn = new ServerConnection(subscriberName);
ServerConnection publisherConn = new ServerConnection(publisherName);
// Create the objects that we need.
TransPublication publication;
TransPullSubscription subscription;
try
{
// Connect to the Publisher and Subscriber.
subscriberConn.Connect();
publisherConn.Connect();
// Ensure that the publication exists and that
// it supports pull subscriptions.
publication = new TransPublication();
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
publication.ConnectionContext = publisherConn;
if (publication.IsExistingObject)
{
if ((publication.Attributes & PublicationAttributes.AllowPull) == 0)
{
publication.Attributes |= PublicationAttributes.AllowPull;
}
// Define the pull subscription.
subscription = new TransPullSubscription();
subscription.ConnectionContext = subscriberConn;
subscription.PublisherName = publisherName;
subscription.PublicationName = publicationName;
subscription.PublicationDBName = publicationDbName;
subscription.DatabaseName = subscriptionDbName;
// Specify the Windows login credentials for the Distribution Agent job.
subscription.SynchronizationAgentProcessSecurity.Login = winLogin;
subscription.SynchronizationAgentProcessSecurity.Password = winPassword;
// Make sure that the agent job for the subscription is created.
subscription.CreateSyncAgentByDefault = true;
// By default, subscriptions to transactional publications are synchronized
// continuously, but in this case we only want to synchronize on demand.
subscription.AgentSchedule.FrequencyType = ScheduleFrequencyType.OnDemand;
// Create the pull subscription at the Subscriber.
subscription.Create();
Boolean registered = false;
// Verify that the subscription is not already registered.
foreach (TransSubscription existing
in publication.EnumSubscriptions())
{
if (existing.SubscriberName == subscriberName
&& existing.SubscriptionDBName == subscriptionDbName)
{
registered = true;
}
}
if (!registered)
{
// Register the subscription with the Publisher.
publication.MakePullSubscriptionWellKnown(
subscriberName, subscriptionDbName,
SubscriptionSyncType.Automatic,
TransSubscriberType.ReadOnly);
}
}
else
{
// Do something here if the publication does not exist.
throw new ApplicationException(String.Format(
"The publication '{0}' does not exist on {1}.",
publicationName, publisherName));
}
}
catch (Exception ex)
{
// Implement the appropriate error handling here.
throw new ApplicationException(String.Format(
"The subscription to {0} could not be created.", publicationName), ex);
}
finally
{
subscriberConn.Disconnect();
publisherConn.Disconnect();
}
' Define the Publisher, publication, and databases.
Dim publicationName As String = "AdvWorksProductTran"
Dim publisherName As String = publisherInstance
Dim subscriberName As String = subscriberInstance
Dim subscriptionDbName As String = "AdventureWorks2012Replica"
Dim publicationDbName As String = "AdventureWorks2012"
'Create connections to the Publisher and Subscriber.
Dim subscriberConn As ServerConnection = New ServerConnection(subscriberName)
Dim publisherConn As ServerConnection = New ServerConnection(publisherName)
' Create the objects that we need.
Dim publication As TransPublication
Dim subscription As TransPullSubscription
Try
' Connect to the Publisher and Subscriber.
subscriberConn.Connect()
publisherConn.Connect()
' Ensure that the publication exists and that
' it supports pull subscriptions.
publication = New TransPublication()
publication.Name = publicationName
publication.DatabaseName = publicationDbName
publication.ConnectionContext = publisherConn
If publication.IsExistingObject Then
If (publication.Attributes And PublicationAttributes.AllowPull) = 0 Then
publication.Attributes = publication.Attributes _
Or PublicationAttributes.AllowPull
End If
' Define the pull subscription.
subscription = New TransPullSubscription()
subscription.ConnectionContext = subscriberConn
subscription.PublisherName = publisherName
subscription.PublicationName = publicationName
subscription.PublicationDBName = publicationDbName
subscription.DatabaseName = subscriptionDbName
subscription.Description = "Pull subscription to " + publicationDbName _
+ " on " + subscriberName + "."
' Specify the Windows login credentials for the Distribution Agent job.
subscription.SynchronizationAgentProcessSecurity.Login = winLogin
subscription.SynchronizationAgentProcessSecurity.Password = winPassword
' Make sure that the agent job for the subscription is created.
subscription.CreateSyncAgentByDefault = True
' By default, subscriptions to transactional publications are synchronized
' continuously, but in this case we only want to synchronize on demand.
subscription.AgentSchedule.FrequencyType = ScheduleFrequencyType.OnDemand
' Create the pull subscription at the Subscriber.
subscription.Create()
Dim registered As Boolean = False
' Verify that the subscription is not already registered.
For Each existing As TransSubscription In publication.EnumSubscriptions()
If existing.SubscriberName = subscriberName And _
existing.SubscriptionDBName = subscriptionDbName Then
registered = True
End If
Next existing
If Not registered Then
' Register the subscription with the Publisher.
publication.MakePullSubscriptionWellKnown( _
subscriberName, subscriptionDbName, _
SubscriptionSyncType.Automatic, _
TransSubscriberType.ReadOnly)
End If
Else
' Do something here if the publication does not exist.
Throw New ApplicationException(String.Format( _
"The publication '{0}' does not exist on {1}.", _
publicationName, publisherName))
End If
Catch ex As Exception
' Implement the appropriate error handling here.
Throw New ApplicationException(String.Format( _
"The subscription to {0} could not be created.", publicationName), ex)
Finally
subscriberConn.Disconnect()
publisherConn.Disconnect()
End Try
注解
对于请求订阅,分发代理在订阅服务器上运行。
线程安全性
Microsoft Visual Basic) 此类型成员中的任何公共静态 Shared
(对于多线程操作都是安全的。 但不保证所有实例成员都是线程安全的。
构造函数
TransPullSubscription() |
创建 TransPullSubscription 类的新实例。 |
TransPullSubscription(String, String, String, String, ServerConnection) |
使用定义请求订阅的属性创建 TransPullSubscription 类的新实例。 |
TransPullSubscription(String, String, String, String, ServerConnection, Boolean) |
使用定义请求订阅以及是否为订阅创建代理作业的属性创建 TransPullSubscription 类的新实例。 |
属性
AgentJobId |
获取用来同步订阅的代理作业的 ID。 (继承自 PullSubscription) |
AgentOffload |
获取或设置同步代理是否运行于创建代理作业的计算机之外的计算机上。 运行 Microsoft SQL Server 2005 及更高版本的分发服务器不再支持此属性。 (继承自 PullSubscription) |
AgentOffloadServer |
获取或设置使用远程代理激活时代理运行于其上的远程计算机的名称。 (继承自 PullSubscription) |
AgentSchedule |
获取用于同步订阅的代理作业的计划。 (继承自 PullSubscription) |
AltSnapshotFolder |
获取或设置在分发服务器上未使用默认快照位置时获取发布快照文件的位置。 (继承自 PullSubscription) |
Attributes |
获取或设置订阅所支持的事务发布的属性。 |
CachePropertyChanges |
获取或设置是缓存对复制属性所做的更改还是立即应用它们。 (继承自 ReplicationObject) |
ConnectionContext |
获取或设置与 Microsoft SQL Server 实例的连接。 (继承自 ReplicationObject) |
CreateSyncAgentByDefault |
获取或设置在创建订阅时是否创建用于启动复制代理以便同步订阅的代理作业。 (继承自 PullSubscription) |
DatabaseName |
获取或设置订阅数据库的名称。 (继承自 PullSubscription) |
Description |
获取或设置请求订阅的文本说明。 (继承自 PullSubscription) |
DistributorName |
获取或设置 Microsoft SQL Server的实例,该实例是分发服务器,并且分发订阅订阅的发布。 (继承自 PullSubscription) |
DistributorSecurity |
获取连接到分发服务器所使用的安全上下文。 (继承自 PullSubscription) |
DtsPackageLocation |
获取或设置用于可转换订阅的 Data Transformation Services (DTS) 包的位置。 |
DtsPackageName |
获取或设置在可转换订阅中使用的 Data Transformation Services (DTS) 包名称。 |
DtsPackagePassword |
获取或设置用于可转换订阅的密码。 |
EnabledForSynchronizationManager |
指定能否使用 Windows 同步管理器同步订阅。 (继承自 PullSubscription) |
FtpAddress |
获取或设置 FTP 服务器的 IP 地址。 (继承自 PullSubscription) |
FtpLogin |
获取或设置 FTP 登录名。 (继承自 PullSubscription) |
FtpPassword |
获取或设置 FTP 密码。 (继承自 PullSubscription) |
FtpPort |
获取或设置 FTP 服务器的端口号。 (继承自 PullSubscription) |
IsExistingObject |
获取服务器上是否存在该对象。 (继承自 ReplicationObject) |
IsMemoryOptimized |
表示对事务发布的请求订阅。 (继承自 PullSubscription) |
LastAgentDateTime |
获取上次同步订阅的日期和时间。 (继承自 PullSubscription) |
LastAgentStatus |
获取订阅的最新同步的状态。 (继承自 PullSubscription) |
LastAgentSummary |
获取订阅的最新同步的结果的摘要。 (继承自 PullSubscription) |
LastSummaryDateTime |
获取完成上次同步的日期和时间。 |
MemoryOptimized |
表示对事务发布的请求订阅。 |
Name |
获取为请求订阅生成的名称。 (继承自 PullSubscription) |
PublicationDBName |
获取或设置发布数据库的名称。 (继承自 PullSubscription) |
PublicationName |
获取或设置订阅订阅的发布的名称。 (继承自 PullSubscription) |
PublisherName |
获取或设置发布服务器的名称。 (继承自 PullSubscription) |
PublisherSecurity |
获取或设置在连接到发布服务器时同步代理使用的安全上下文。 (继承自 PullSubscription) |
SecureFtpPassword |
获取或设置用于连接到 FTP 服务器的登录名的安全密码。 (继承自 PullSubscription) |
SqlServerName |
获取此对象连接到的 Microsoft SQL Server 实例的名称。 (继承自 ReplicationObject) |
SubscriberSecurity |
获取在连接到订阅服务器时同步代理使用的安全上下文。 (继承自 PullSubscription) |
SubscriberType |
获取或设置订阅的更新行为。 |
SubscriptionId |
获取订阅 ID 值。 (继承自 PullSubscription) |
SubscriptionType |
获取该订阅注册是用于推送订阅、请求订阅还是匿名订阅。 (继承自 PullSubscription) |
SynchronizationAgent |
获取一个对象,该对象表示可用于同步订阅的分发代理的实例。 |
SynchronizationAgentProcessSecurity |
获取用于指定运行同步代理作业以同步订阅的 Microsoft Windows 帐户的安全上下文。 (继承自 PullSubscription) |
Type |
获取或设置发布类型。 (继承自 PullSubscription) |
UseFtp |
获取或设置同步代理是否使用文件传输协议 (FTP) 访问初始化请求订阅所需的快照文件。 (继承自 PullSubscription) |
UserData |
获取或设置允许用户将他们自己的数据附加到该对象的对象属性。 (继承自 ReplicationObject) |
WorkingDirectory |
获取或设置订阅服务器上用于临时存储和解压缩下载的快照文件的目录的路径。 (继承自 PullSubscription) |