Помогите, создаю репликацию руками, всё проходит нормально, SnapShot работает, как только создаю репликацию программно (RMO) , то репликация создаётся, а SnapShot выкидывает ошибку, типа измени параметер в sp_changemergepublication use_partition_groups на true. пытался сделать вручную, выкидывает ошибку - изменения не работают для Merge репликации. код Код | Public Function CreateReplikation(ByVal SL As ServerLogin) As Boolean Dim conn As New Microsoft.SqlServer.Management.Common.ServerConnection(SL.Server, SL.User, SL.Passwort) Dim publication As New Microsoft.SqlServer.Replication.MergePublication(SL.Database, SL.Database, conn) Dim res As Boolean = True Try ' Connect to the Publisher. conn.Connect() Dim publicationDb As New ReplicationDatabase(SL.Database, 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, SL.Database)) End If
' Set the required properties for the merge publication. publication = New MergePublication() publication.ConnectionContext = conn publication.Name = SL.Database publication.DatabaseName = SL.Database
' Enable precomputed partitions. publication.PartitionGroupsOption = PartitionGroupsOption.True
' 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 = SL.User publication.SnapshotGenerationAgentProcessSecurity.Password = SL.Passwort
' Explicitly set the security mode for the Publisher connection ' Windows Authentication (the default). publication.SnapshotGenerationAgentPublisherSecurity.WindowsAuthentication = True
' Enable Subscribers to request snapshot generation and filtering. publication.Attributes = publication.Attributes Or _ PublicationAttributes.AllowSubscriberInitiatedSnapshot publication.Attributes = publication.Attributes Or _ PublicationAttributes.DynamicFilters
' Enable pull and push subscriptions publication.Attributes = publication.Attributes Or _ PublicationAttributes.AllowPull publication.Attributes = publication.Attributes Or _ PublicationAttributes.AllowPush
If Not publication.IsExistingObject Then ' Create the merge publication. publication.Create()
' Create a Snapshot Agent job for the publication. 'publication.CreateSnapshotAgent() Else Throw New ApplicationException(String.Format( _ "The {0} publication already exists.", SL.Database)) End If Catch ex As Exception res = False ' Implement custom application error handling here. Throw New ApplicationException(String.Format( _ "The publication {0} could not be created.", SL.Database), ex) Finally conn.Disconnect() End Try Return res End Function
|
|