TransPublication クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
取引出版物を表します。
public ref class TransPublication sealed : Microsoft::SqlServer::Replication::Publication
public sealed class TransPublication : Microsoft.SqlServer.Replication.Publication
type TransPublication = class
inherit Publication
Public NotInheritable Class TransPublication
Inherits Publication
- 継承
例
この例はトランザクション出版物を作成します。
// Set the Publisher, publication database, and publication names.
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2012";
string publisherName = publisherInstance;
ReplicationDatabase publicationDb;
TransPublication publication;
// Create a connection to the Publisher using Windows Authentication.
ServerConnection conn;
conn = new ServerConnection(publisherName);
try
{
// Connect to the Publisher.
conn.Connect();
// Enable the AdventureWorks2012 database for transactional publishing.
publicationDb = new ReplicationDatabase(publicationDbName, conn);
// If the database exists and is not already enabled,
// enable it for transactional publishing.
if (publicationDb.LoadProperties())
{
if (!publicationDb.EnabledTransPublishing)
{
publicationDb.EnabledTransPublishing = true;
}
// If the Log Reader Agent does not exist, create it.
if (!publicationDb.LogReaderAgentExists)
{
// Specify the Windows account under which the agent job runs.
// This account will be used for the local connection to the
// Distributor and all agent connections that use Windows Authentication.
publicationDb.LogReaderAgentProcessSecurity.Login = winLogin;
publicationDb.LogReaderAgentProcessSecurity.Password = winPassword;
// Explicitly set authentication mode for the Publisher connection
// to the default value of Windows Authentication.
publicationDb.LogReaderAgentPublisherSecurity.WindowsAuthentication = true;
// Create the Log Reader Agent job.
publicationDb.CreateLogReaderAgent();
}
}
else
{
throw new ApplicationException(String.Format(
"The {0} database does not exist at {1}.",
publicationDb, publisherName));
}
// Set the required properties for the transactional publication.
publication = new TransPublication();
publication.ConnectionContext = conn;
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
// Specify a transactional publication (the default).
publication.Type = PublicationType.Transactional;
// Activate the publication so that we can add subscriptions.
publication.Status = State.Active;
// Enable push and pull subscriptions and independent Distribition Agents.
publication.Attributes |= PublicationAttributes.AllowPull;
publication.Attributes |= PublicationAttributes.AllowPush;
publication.Attributes |= PublicationAttributes.IndependentAgent;
// Specify the Windows account under which the Snapshot Agent job runs.
// This account will be used for the local connection to the
// Distributor and all agent connections that use Windows Authentication.
publication.SnapshotGenerationAgentProcessSecurity.Login = winLogin;
publication.SnapshotGenerationAgentProcessSecurity.Password = winPassword;
// Explicitly set the security mode for the Publisher connection
// Windows Authentication (the default).
publication.SnapshotGenerationAgentPublisherSecurity.WindowsAuthentication = true;
if (!publication.IsExistingObject)
{
// Create the transactional publication.
publication.Create();
// Create a Snapshot Agent job for the publication.
publication.CreateSnapshotAgent();
}
else
{
throw new ApplicationException(String.Format(
"The {0} publication already exists.", publicationName));
}
}
catch (Exception ex)
{
// Implement custom application error handling here.
throw new ApplicationException(String.Format(
"The publication {0} could not be created.", publicationName), ex);
}
finally
{
conn.Disconnect();
}
' Set the Publisher, publication database, and publication names.
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"
Dim publisherName As String = publisherInstance
Dim publicationDb As ReplicationDatabase
Dim publication As TransPublication
' Create a connection to the Publisher using Windows Authentication.
Dim conn As ServerConnection
conn = New ServerConnection(publisherName)
Try
' Connect to the Publisher.
conn.Connect()
' Enable the AdventureWorks2012 database for transactional publishing.
publicationDb = New ReplicationDatabase(publicationDbName, conn)
' If the database exists and is not already enabled,
' enable it for transactional publishing.
If publicationDb.LoadProperties() Then
If Not publicationDb.EnabledTransPublishing Then
publicationDb.EnabledTransPublishing = True
End If
' If the Log Reader Agent does not exist, create it.
If Not publicationDb.LogReaderAgentExists Then
' Specify the Windows account under which the agent job runs.
' This account will be used for the local connection to the
' Distributor and all agent connections that use Windows Authentication.
publicationDb.LogReaderAgentProcessSecurity.Login = winLogin
publicationDb.LogReaderAgentProcessSecurity.Password = winPassword
' Explicitly set authentication mode for the Publisher connection
' to the default value of Windows Authentication.
publicationDb.LogReaderAgentPublisherSecurity.WindowsAuthentication = True
' Create the Log Reader Agent job.
publicationDb.CreateLogReaderAgent()
End If
Else
Throw New ApplicationException(String.Format( _
"The {0} database does not exist at {1}.", _
publicationDb, publisherName))
End If
' Set the required properties for the transactional publication.
publication = New TransPublication()
publication.ConnectionContext = conn
publication.Name = publicationName
publication.DatabaseName = publicationDbName
' Specify a transactional publication (the default).
publication.Type = PublicationType.Transactional
'Enable push and pull subscriptions and independent Distribition Agents.
publication.Attributes = _
publication.Attributes Or PublicationAttributes.AllowPull
publication.Attributes = _
publication.Attributes Or PublicationAttributes.AllowPush
publication.Attributes = _
publication.Attributes Or PublicationAttributes.IndependentAgent
' Activate the publication so that we can add subscriptions.
publication.Status = State.Active
' Specify the Windows account under which the Snapshot Agent job runs.
' This account will be used for the local connection to the
' Distributor and all agent connections that use Windows Authentication.
publication.SnapshotGenerationAgentProcessSecurity.Login = winLogin
publication.SnapshotGenerationAgentProcessSecurity.Password = winPassword
' Explicitly set the security mode for the Publisher connection
' Windows Authentication (the default).
publication.SnapshotGenerationAgentPublisherSecurity.WindowsAuthentication = True
If Not publication.IsExistingObject Then
' Create the transactional publication.
publication.Create()
' Create a Snapshot Agent job for the publication.
publication.CreateSnapshotAgent()
Else
Throw New ApplicationException(String.Format( _
"The {0} publication already exists.", publicationName))
End If
Catch ex As Exception
' Implement custom application error handling here.
Throw New ApplicationException(String.Format( _
"The publication {0} could not be created.", publicationName), ex)
Finally
conn.Disconnect()
End Try
この例はトランザクション出版物を削除します。
// Define the Publisher, publication database,
// and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2012";
TransPublication publication;
ReplicationDatabase publicationDb;
// Create a connection to the Publisher
// using Windows Authentication.
ServerConnection conn = new ServerConnection(publisherName);
try
{
conn.Connect();
// Set the required properties for the transactional publication.
publication = new TransPublication();
publication.ConnectionContext = conn;
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
// Delete the publication, if it exists and has no subscriptions.
if (publication.LoadProperties() && !publication.HasSubscription)
{
publication.Remove();
}
else
{
// Do something here if the publication does not exist
// or has subscriptions.
throw new ApplicationException(String.Format(
"The publication {0} could not be deleted. " +
"Ensure that the publication exists and that all " +
"subscriptions have been deleted.",
publicationName, publisherName));
}
// If no other transactional publications exists,
// disable publishing on the database.
publicationDb = new ReplicationDatabase(publicationDbName, conn);
if (publicationDb.LoadProperties())
{
if (publicationDb.TransPublications.Count == 0)
{
publicationDb.EnabledTransPublishing = false;
}
}
else
{
// Do something here if the database does not exist.
throw new ApplicationException(String.Format(
"The database {0} does not exist on {1}.",
publicationDbName, publisherName));
}
}
catch (Exception ex)
{
// Implement application error handling here.
throw new ApplicationException(String.Format(
"The publication {0} could not be deleted.",
publicationName), ex);
}
finally
{
conn.Disconnect();
}
' Define the Publisher, publication database,
' and publication names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"
Dim publication As TransPublication
Dim publicationDb As ReplicationDatabase
' Create a connection to the Publisher
' using Windows Authentication.
Dim conn As ServerConnection = New ServerConnection(publisherName)
Try
conn.Connect()
' Set the required properties for the transactional publication.
publication = New TransPublication()
publication.ConnectionContext = conn
publication.Name = publicationName
publication.DatabaseName = publicationDbName
' Delete the publication, if it exists and has no subscriptions.
If publication.LoadProperties() And Not publication.HasSubscription Then
publication.Remove()
Else
' Do something here if the publication does not exist
' or has subscriptions.
Throw New ApplicationException(String.Format( _
"The publication {0} could not be deleted. " + _
"Ensure that the publication exists and that all " + _
"subscriptions have been deleted.", _
publicationName, publisherName))
End If
' If no other transactional publications exists,
' disable publishing on the database.
publicationDb = New ReplicationDatabase(publicationDbName, conn)
If publicationDb.LoadProperties() Then
If publicationDb.TransPublications.Count = 0 Then
publicationDb.EnabledTransPublishing = False
End If
Else
' Do something here if the database does not exist.
Throw New ApplicationException(String.Format( _
"The database {0} does not exist on {1}.", _
publicationDbName, publisherName))
End If
Catch ex As Exception
' Implement application error handling here.
Throw New ApplicationException(String.Format( _
"The publication {0} could not be deleted.", _
publicationName), ex)
Finally
conn.Disconnect()
End Try
注釈
スレッド セーフ
このタイプの公開静的(Microsoft Visual BasicShared)メンバーはマルチスレッド操作に安全です。 インスタンス メンバーがスレッド セーフであるとは限りません。
コンストラクター
| 名前 | 説明 |
|---|---|
| TransPublication() |
TransPublication クラスの新しいインスタンスを作成します。 |
| TransPublication(String, String, ServerConnection, Boolean) |
必要なプロパティを持つTransPublicationクラスの新しいインスタンスを作成し、出版のスナップショット エージェントジョブが作成されるかどうかを示します。 |
| TransPublication(String, String, ServerConnection) |
必要なプロパティを持つ TransPublication クラスの新しいインスタンスを作成します。 |
プロパティ
| 名前 | 説明 |
|---|---|
| AltSnapshotFolder |
出版物の代替スナップショットファイル位置を取得したり設定したりします。 (継承元 Publication) |
| Attributes |
出版属性を取得したり設定したりします。 (継承元 Publication) |
| CachePropertyChanges |
レプリケーションプロパティの変更をキャッシュするか、即座に適用するかを取得または設定します。 (継承元 ReplicationObject) |
| CompatibilityLevel |
参照された出版物がサポート可能なMicrosoft SQL Serverの最早バージョンをSubscribers上で取得または設定します。 (継承元 Publication) |
| ConflictPolicy |
購読の更新をサポートする出版物の競合ポリシーを取得または設定します。 |
| ConflictRetention |
競合データ行が競合テーブルに保持される日数を取得または設定します。 (継承元 Publication) |
| ConnectionContext |
Microsoft SQL Serverのインスタンスへの接続を取得または設定します。 (継承元 ReplicationObject) |
| ContinueOnConflict |
競合が検出された後も、ディストリビューション エージェントが変更の処理を継続するかどうかを決定します。 |
| CreateSnapshotAgentByDefault |
スナップショット エージェントジョブがパブリケーション作成時に自動的に追加された場合、取得または設定されます。 (継承元 Publication) |
| DatabaseName |
出版物データベースの名前を取得するか設定します。 (継承元 Publication) |
| Description |
出版物のテキスト説明を取得または設定します。 (継承元 Publication) |
| FtpAddress |
FTP経由で購読初期化が可能な出版のために、ファイル転送プロトコル(FTP)サーバーコンピュータのアドレスを取得したり設定したりします。 (継承元 Publication) |
| FtpLogin |
FTP経由で購読初期化が可能な出版のために、ファイル転送プロトコル(FTP)サーバーに接続するためのログインを取得または設定します。 (継承元 Publication) |
| FtpPassword |
FTP経由で購読初期化が可能な出版物のファイル転送プロトコル(FTP)サーバーに接続するためのログインパスワードを設定します。 (継承元 Publication) |
| FtpPort |
FTPによる購読初期化が可能な出版のために、ファイル転送プロトコル(FTP)サーバーコンピュータのポートを取得したり設定したりします。 (継承元 Publication) |
| FtpSubdirectory |
FTPサーバー上のサブディレクトリを取得したり設定したりし、FTP経由で購読初期化が可能な出版物を扱います。 (継承元 Publication) |
| HasSubscription |
出版物が1つ以上の購読者かどうかを把握します。 (継承元 Publication) |
| IsExistingObject |
オブジェクトがサーバー上に存在するかどうかを把握します。 (継承元 ReplicationObject) |
| Name |
出版物の名前を取得するか設定します。 (継承元 Publication) |
| PeerConflictDetectionEnabled |
SetPeerConflictDetection(Boolean, Int32)を使ってピアツーピアの競合検出が有効になったかどうかを把握します。 |
| PeerOriginatorID |
ピアツーピアトポロジーのノードIDを取得します。このIDは、 PeerConflictDetectionEnabled が |
| PostSnapshotScript |
サブスクライバーに初期スナップショットが適用された後に実行される Transact-SQL スクリプトファイルの名前とフルパスを取得します。 (継承元 Publication) |
| PreSnapshotScript |
初期スナップショットがサブスクライバーに適用される前に実行される Transact-SQL スクリプトファイルの名前とフルパスを取得します。 (継承元 Publication) |
| PubId |
出版物を一意に識別する価値を取得します。 (継承元 Publication) |
| PublisherName |
非SQL Server Publisherの名前を取得または設定します。 |
| QueueType |
キュー付き更新サブスクリプションを許可する出版物に使用するキューの種類を取得したり設定したりします。 |
| ReplicateDdl |
DDLの変更が複製されるかどうかを判定するデータ定義言語(DDL)のレプリケーションオプションを取得したり設定したりします。 (継承元 Publication) |
| RetentionPeriod |
購読が出版物と同期していない場合、その期間が切れるまでの期間を取得または設定します。 (継承元 Publication) |
| SecureFtpPassword |
FTPを経由した購読初期化が可能な出版物のファイル転送プロトコル(FTP)サーバーに接続するためのログインのパスワード( SecureString オブジェクトとして)を設定します。 (継承元 Publication) |
| SnapshotAgentExists |
この公開の初期スナップショットを生成するためにSQL Server エージェントジョブが存在するかどうかを取得します。 (継承元 Publication) |
| SnapshotAvailable |
この出版物のスナップショットファイルが利用可能かどうかを把握します。 |
| SnapshotGenerationAgentProcessSecurity |
スナップショット エージェントジョブが実行されるWindowsアカウントを設定するオブジェクトを取得します。 (継承元 Publication) |
| SnapshotGenerationAgentPublisherSecurity |
スナップショット エージェントがPublisherに接続するために使用するセキュリティコンテキストを取得します。 (継承元 Publication) |
| SnapshotJobId |
現在の出版物のスナップショット エージェントジョブIDを取得します。 (継承元 Publication) |
| SnapshotMethod |
初期スナップショットのデータファイル形式を取得するか設定します。 (継承元 Publication) |
| SnapshotSchedule |
現在の出版のスナップショット エージェントのスケジュールを設定するオブジェクトを取得します。 (継承元 Publication) |
| SqlServerName |
このオブジェクトが接続されているMicrosoft SQL Serverインスタンスの名前を取得します。 (継承元 ReplicationObject) |
| Status |
出版物のステータスを取得するか設定します。 (継承元 Publication) |
| TransArticles |
出版物の記事を代表します。 |
| TransSubscriptions |
出版物の購読を代表します。 |
| Type |
出版物の種類を取得または決定します。 (継承元 Publication) |
| UserData |
ユーザーが自分のデータをオブジェクトにアタッチできるオブジェクトプロパティを取得したり設定したりします。 (継承元 ReplicationObject) |