TransSubscription クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
トランザクションまたはスナップショット出版物へのプッシュサブスクリプションを表します。
public ref class TransSubscription sealed : Microsoft::SqlServer::Replication::Subscription
public sealed class TransSubscription : Microsoft.SqlServer.Replication.Subscription
type TransSubscription = class
inherit Subscription
Public NotInheritable Class TransSubscription
Inherits Subscription
- 継承
例
// Define the Publisher, publication, and databases.
string publicationName = "AdvWorksProductTran";
string publisherName = publisherInstance;
string subscriberName = subscriberInstance;
string subscriptionDbName = "AdventureWorks2012Replica";
string publicationDbName = "AdventureWorks2012";
//Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);
// Create the objects that we need.
TransPublication publication;
TransSubscription subscription;
try
{
// Connect to the Publisher.
conn.Connect();
// Ensure that the publication exists and that
// it supports push subscriptions.
publication = new TransPublication();
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
publication.ConnectionContext = conn;
if (publication.IsExistingObject)
{
if ((publication.Attributes & PublicationAttributes.AllowPush) == 0)
{
publication.Attributes |= PublicationAttributes.AllowPush;
}
// Define the push subscription.
subscription = new TransSubscription();
subscription.ConnectionContext = conn;
subscription.SubscriberName = subscriberName;
subscription.PublicationName = publicationName;
subscription.DatabaseName = publicationDbName;
subscription.SubscriptionDBName = subscriptionDbName;
// Specify the Windows login credentials for the Distribution Agent job.
subscription.SynchronizationAgentProcessSecurity.Login = winLogin;
subscription.SynchronizationAgentProcessSecurity.Password = winPassword;
// 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 push subscription.
subscription.Create();
}
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
{
conn.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 a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)
' Create the objects that we need.
Dim publication As TransPublication
Dim subscription As TransSubscription
Try
' Connect to the Publisher.
conn.Connect()
' Ensure that the publication exists and that
' it supports push subscriptions.
publication = New TransPublication()
publication.Name = publicationName
publication.DatabaseName = publicationDbName
publication.ConnectionContext = conn
If publication.IsExistingObject Then
If (publication.Attributes And PublicationAttributes.AllowPush) = 0 Then
publication.Attributes = publication.Attributes _
Or PublicationAttributes.AllowPush
End If
' Define the push subscription.
subscription = New TransSubscription()
subscription.ConnectionContext = conn
subscription.SubscriberName = subscriberName
subscription.PublicationName = publicationName
subscription.DatabaseName = publicationDbName
subscription.SubscriptionDBName = subscriptionDbName
' Specify the Windows login credentials for the Distribution Agent job.
subscription.SynchronizationAgentProcessSecurity.Login = winLogin
subscription.SynchronizationAgentProcessSecurity.Password = winPassword
' 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 push subscription.
subscription.Create()
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
conn.Disconnect()
End Try
注釈
リモートディストリビューターでPublisherを設定する際、SynchronizationAgentProcessSecurityを含むすべてのパラメータの値がプレーンテキストでディストリビュータに送信されます。 Create メソッドを呼び出す前に、パブリッシャーとリモート ディストリビューター間の接続を暗号化する必要があります。 詳細については、 sp_reinitsubscription(Transact-SQL)を参照してください。
購読が非SQL Server Publisherに属する場合、ConnectionContextプロパティはPublisherではなくディストリビューターに設定され、DatabaseNameプロパティは出版データベースではなく配布データベースに、PublisherNameプロパティは非SQL Server Publisherの名前に設定されます。
スレッド セーフ
このタイプの公開静的(Microsoft Visual BasicShared)メンバーはマルチスレッド操作に安全です。 インスタンス メンバーがスレッド セーフであるとは限りません。
コンストラクター
| 名前 | 説明 |
|---|---|
| TransSubscription() |
TransSubscription クラスの新しいインスタンスを作成します。 |
| TransSubscription(String, String, String, String, ServerConnection) |
指定された公開、データベース、サブスクライバー、サブスクライバーデータベース、そしてMicrosoft SQL Serverインスタンスへの指定された接続を持つ新しいインスタンスTransSubscriptionクラスを作成します。 |
プロパティ
| 名前 | 説明 |
|---|---|
| AgentJobId |
サブスクリプション同期に使われたエージェントジョブのIDを取得します。 (継承元 Subscription) |
| AgentOffload |
同期エージェントがエージェントジョブが作成されたコンピュータ以外のコンピュータ上で動作するかを取得または設定します。 このプロパティは、Microsoft SQL Server 2005以降のディストリビューターではもはやサポートされていません。 (継承元 Subscription) |
| AgentOffloadServer |
リモートエージェントのアクティベーション時にエージェントが動作するリモートコンピュータの名前を取得したり設定したりします。 (継承元 Subscription) |
| AgentSchedule |
サブスクリプション同期に使われるエージェントジョブのスケジュールを取得します。 (継承元 Subscription) |
| BackupInformation |
バックアップからサブスクリプションの初期化に必要な情報を取得または設定します。 |
| CachePropertyChanges |
レプリケーションプロパティの変更をキャッシュするか、即座に適用するかを取得または設定します。 (継承元 ReplicationObject) |
| ConnectionContext |
Microsoft SQL Serverのインスタンスへの接続を取得または設定します。 (継承元 ReplicationObject) |
| CreateSyncAgentByDefault |
サブスクリプション同期に使われるエージェントジョブがデフォルトで作成されるかどうかを取得または設定します。 (継承元 Subscription) |
| DatabaseName |
出版物データベースの名前を取得するか設定します。 (継承元 Subscription) |
| DtsPackageLocation |
Microsoft SQL Server 2000 Data Transformation Services(DTS)パッケージの位置を取得したり設定したりします。 |
| DtsPackageName |
加入者に適用されるMicrosoft SQL Server 2000データ変換サービス(DTS)パッケージの名前を取得したり設定したりします。 |
| DtsPackagePassword |
Microsoft SQL Server 2000 Data Transformation Services(DTS)パッケージを実行する際に使用されるパスワードを設定します。 |
| EnabledForSynchronizationManager |
同期マネージャーを使ってサブスクリプションを同期できるかどうかMicrosoft Windows指定します。 (継承元 Subscription) |
| FullSubscription |
サブスクリプションが満員かどうかを示す値が表示されます。 |
| IsExistingObject |
オブジェクトがサーバー上に存在するかどうかを把握します。 (継承元 ReplicationObject) |
| LoopBackDetection |
ディストリビューション エージェントが加入者から発生したトランザクションを加入者に返送するか、取得するか設定します。 |
| MemoryOptimized |
トランザクションまたはスナップショット出版物へのプッシュサブスクリプションを表します。 |
| Name |
既存のサブスクリプションに名前が割り当てられます。 (継承元 Subscription) |
| PublicationName |
購読者が購読している出版物の名前を取得するか設定します。 (継承元 Subscription) |
| PublisherName |
サブスクリプションが非SQL Server Publisherに属している場合、Publisherの名前を取得するか設定します。 |
| SecureDtsPackagePassword |
Microsoft SQL Server 2000 Data Transformation Services(DTS)パッケージを実行する際に使うパスワード(SecureStringオブジェクトとして)を設定します。 |
| SqlServerName |
このオブジェクトが接続されているMicrosoft SQL Serverインスタンスの名前を取得します。 (継承元 ReplicationObject) |
| Status |
サブスクリプションの状況を把握します。 (継承元 Subscription) |
| SubscriberCatalog |
非SQL Serverサブスクライバー向けにOLE DBプロバイダーに接続する際に使われるカタログを取得したり設定したりします。 |
| SubscriberDatasource |
非SQL Serverサブスクライバーの場合、OLE DBプロバイダーが理解するデータソースの名前。 |
| SubscriberDatasourceType |
非SQL Serverサブスクライバーとなるデータソースの種類を特定します。 |
| SubscriberLocation |
非SQL Serverサブスクライバー向けにOLE DBプロバイダーが理解するデータベースの位置。 |
| SubscriberName |
サブスクライバーであるMicrosoft SQL Serverのインスタンス名を取得したり設定したりします。 (継承元 Subscription) |
| SubscriberProvider |
非SQL ServerサブスクライバーのOLE DBプロバイダーが登録される固有のプログラム識別子(PROGID) |
| SubscriberProviderString |
OLE DBプロバイダー固有の接続文字列は、SQL Serverを使わないサブスクライバーのデータソースに接続するために使われます。 |
| SubscriberSecurity |
加入者に接続する際に使われるセキュリティコンテキストを取得します。 (継承元 Subscription) |
| SubscriberType |
サブスクライバーでデータ変更の更新動作を取得または設定します。 |
| SubscriptionDBName |
複製されたデータを受け取ったサブスクライバーのデータベース名を取得するか設定します。 (継承元 Subscription) |
| SubscriptionLSN |
サブスクリプションのログシーケンス番号を取得したり設定したりします。 |
| SubscriptionType |
サブスクリプション登録がプッシュ用かプル用かを把握します。 (継承元 Subscription) |
| SynchronizationAgent |
サブスクリプションの同期に使える TransSynchronizationAgent クラスのインスタンスを取得します。 |
| SynchronizationAgentName |
サブスクリプションを同期するために作成されたエージェントジョブの名前を取得したり設定したりします。 (継承元 Subscription) |
| SynchronizationAgentProcessSecurity |
同期エージェントジョブが実行されるMicrosoft Windowsアカウントを指定するためのセキュリティコンテキストを取得し、サブスクリプションを同期させます。 (継承元 Subscription) |
| SyncType |
サブスクリプションの初期化方法を取得または設定します。 (継承元 Subscription) |
| UserData |
ユーザーが自分のデータをオブジェクトにアタッチできるオブジェクトプロパティを取得したり設定したりします。 (継承元 ReplicationObject) |
メソッド
| 名前 | 説明 |
|---|---|
| CheckValidCreation() |
有効な複製の作成を確認します。 (継承元 ReplicationObject) |
| CheckValidDefinition(Boolean) |
サブスクリプションの定義が有効かどうかを示します。 (継承元 Subscription) |
| CommitPropertyChanges() |
キャッシュされたプロパティ変更文をすべてMicrosoft SQL Serverのインスタンスに送信します。 (継承元 ReplicationObject) |
| Create() |
Publisherで購読登録を作成します。 (継承元 Subscription) |
| Decouple() |
参照されたレプリケーションオブジェクトをサーバーから切り離します。 (継承元 ReplicationObject) |
| DoUpdateMemoryOptimizedProperty(String) |
トランザクションまたはスナップショット出版物へのプッシュサブスクリプションを表します。 |
| GetChangeCommand(StringBuilder, String, String) |
レプリケーションからの変更コマンドを返します。 (継承元 ReplicationObject) |
| GetCreateCommand(StringBuilder, Boolean, ScriptOptions) |
レプリケーションからcreateコマンドを返します。 (継承元 ReplicationObject) |
| GetDropCommand(StringBuilder, Boolean) |
レプリケーションからドロップコマンドを返します。 (継承元 ReplicationObject) |
| InternalRefresh(Boolean) |
レプリケーションから内部リフレッシュを開始します。 (継承元 ReplicationObject) |
| Load() |
サーバーから既存のオブジェクトのプロパティを読み込みます。 (継承元 ReplicationObject) |
| LoadProperties() |
サーバーから既存のオブジェクトのプロパティを読み込みます。 (継承元 ReplicationObject) |
| Refresh() |
オブジェクトのプロパティをリロードします。 (継承元 ReplicationObject) |
| Reinitialize() |
次にディストリビューション エージェントが起動してサブスクリプションを同期する際に、サブスクリプションの初期化をマークします。 |
| Reinitialize(Boolean) |
サブスクリプションを再初期化します。 |
| Remove() |
Publisherでのサブスクリプション登録を削除し、Subscriberのプッシュサブスクリプションのレプリケーションオブジェクトを削除します。 (継承元 Subscription) |
| Script(ScriptOptions) |
サブスクリプションの作成または削除に使える Transact-SQL スクリプトを返します。 (継承元 Subscription) |
| StopSynchronizationJob() |
現在サブスクリプションを同期している実行中の ディストリビューション エージェント ジョブを停止しようとします。 |
| SynchronizeWithJob() |
サブスクリプションの同期のためにエージェントジョブを開始します。 |