Publication.Attributes Eigenschaft
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Ruft die Veröffentlichungsattribute ab oder legt sie fest.
public:
property Microsoft::SqlServer::Replication::PublicationAttributes Attributes { Microsoft::SqlServer::Replication::PublicationAttributes get(); void set(Microsoft::SqlServer::Replication::PublicationAttributes value); };
public Microsoft.SqlServer.Replication.PublicationAttributes Attributes { get; set; }
member this.Attributes : Microsoft.SqlServer.Replication.PublicationAttributes with get, set
Public Property Attributes As PublicationAttributes
Eigenschaftswert
Ein PublicationAttributes-Enumerationswert.
Beispiele
// Set the Publisher, publication database, and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksSalesOrdersMerge";
string publicationDbName = "AdventureWorks2012";
ReplicationDatabase publicationDb;
MergePublication publication;
// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);
try
{
// Connect to the Publisher.
conn.Connect();
// Enable the database for merge publication.
publicationDb = new ReplicationDatabase(publicationDbName, conn);
if (publicationDb.LoadProperties())
{
if (!publicationDb.EnabledMergePublishing)
{
publicationDb.EnabledMergePublishing = true;
}
}
else
{
// Do something here if the database does not exist.
throw new ApplicationException(String.Format(
"The {0} database does not exist on {1}.",
publicationDb, publisherName));
}
// Set the required properties for the merge publication.
publication = new MergePublication();
publication.ConnectionContext = conn;
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
// Enable Web synchronization, if not already enabled.
if ((publication.Attributes & PublicationAttributes.AllowWebSynchronization) == 0)
{
publication.Attributes |= PublicationAttributes.AllowWebSynchronization;
}
// Enable pull subscriptions, if not already enabled.
if ((publication.Attributes & PublicationAttributes.AllowPull) == 0)
{
publication.Attributes |= PublicationAttributes.AllowPull;
}
// Enable Subscriber requested snapshot generation.
publication.Attributes |= PublicationAttributes.AllowSubscriberInitiatedSnapshot;
// Enable anonymous access for Subscribers that cannot make a direct connetion
// to the Publisher.
publication.Attributes |= PublicationAttributes.AllowAnonymous;
// 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 merge publication and the Snapshot Agent job.
publication.Create();
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 publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2012"
Dim publicationDb As ReplicationDatabase
Dim publication As MergePublication
' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)
Try
' Connect to the Publisher.
conn.Connect()
' Enable the database for merge publication.
publicationDb = New ReplicationDatabase(publicationDbName, conn)
If publicationDb.LoadProperties() Then
If Not publicationDb.EnabledMergePublishing Then
publicationDb.EnabledMergePublishing = True
End If
Else
' Do something here if the database does not exist.
Throw New ApplicationException(String.Format( _
"The {0} database does not exist on {1}.", _
publicationDb, publisherName))
End If
' Set the required properties for the merge publication.
publication = New MergePublication()
publication.ConnectionContext = conn
publication.Name = publicationName
publication.DatabaseName = publicationDbName
' Enable Web synchronization, if not already enabled.
If (publication.Attributes And PublicationAttributes.AllowWebSynchronization) = 0 Then
publication.Attributes = publication.Attributes _
Or PublicationAttributes.AllowWebSynchronization
End If
' Enable pull subscriptions, if not already enabled.
If (publication.Attributes And PublicationAttributes.AllowPull) = 0 Then
publication.Attributes = publication.Attributes _
Or PublicationAttributes.AllowPull
End If
' Enable Subscriber requested snapshot generation.
publication.Attributes = publication.Attributes _
Or PublicationAttributes.AllowSubscriberInitiatedSnapshot
' Enable anonymous access for Subscribers that cannot
' make a direct connetion to the Publisher.
publication.Attributes = publication.Attributes _
Or PublicationAttributes.AllowAnonymous
' 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 merge publication and the Snapshot Agent job.
publication.Create()
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
Hinweise
Die PublicationAttributes -Enumeration unterstützt die FlagsAttribute -Option, die eine bitweise Kombination von Enumerationswerten zulässt. Unter sp_addpublication (Transact-SQL) und sp_addmergepublication (Transact-SQL) finden Sie Informationen zu Standardattributewerten für Transaktions- oder Momentaufnahmeveröffentlichungen bzw. Mergeveröffentlichungen.
Die Attributes Eigenschaft kann nur von Mitgliedern der sysadmin
festen Serverrolle auf dem Verleger, von Mitgliedern der db_owner
festen Datenbankrolle in der Veröffentlichungsdatenbank oder von Benutzern in der Veröffentlichungszugriffsliste (Pal) abgerufen werden.
Die Attributes -Eigenschaft kann nur von Mitgliedern der sysadmin
festen Serverrolle auf dem Verleger oder von Mitgliedern der db_owner
festen Datenbankrolle in der Veröffentlichungsdatenbank festgelegt werden. Benutzer im PAL können die Attributes -Eigenschaft einer vorhandenen Veröffentlichung festlegen.
Das Abrufen der Attributes Eigenschaft entspricht der Ausführung sp_helppublication oder sp_helpmergepublication.
Das Festlegen der Attributes Eigenschaft entspricht dem Ausführen sp_addpublication und sp_changepublication oder sp_addmergepublication und sp_changemergepublication.