Hi all, I'm new in Merge Replication and I don't know how to solve my problem.
I have 2 computer:
- PC1: Distribution and publication server (Windows Server 2008R2)
- PC2: Subscriber (Windows 7)
I have 1 database on PC1: DB_NAME
I defined these accounts:
- PC1: SQL account PC1_AC1 (account for distribution and publication), Windows Account PC1_AC2 (account for snapshot agent)
- PC2: Windows Account PC2_AC1.
I set the following rights:
- PC1_AC1: db_owner of distribution database, db_owner of database DB_NAME, Roles: public, serveradmin
- PC1_AC2:db_owner of distribution database, db_owner of database DB_NAME, granted access of the "repldata" folder (read/write). Role: public, sysadmin
I set the distribution server and created a publication correctly. On PC2, from code, I created a subscriber and when I try to synchronize the subscriber database with the publisher I have this error:
"The schema script 'TableName_2.sch' could not be propagated to the subscriber. OS error 1326 username or password not valid."
I don't understand where is the problem because from windows I can reach the snapshot folder "\\<server_name>\repldata\unc\" with PC1_AC2 account but apparently not from code. I'm executing this code:
MergeSynchronizationAgent syncAgent;
MergePullSubscription mergePullSub = new MergePullSubscription();
mergePullSub.ConnectionContext = <connection_name>;
mergePullSub.PublicationName = <publication_name>;
mergePullSub.PublisherName = <publicher_name>;
mergePullSub.PublicationDBName = DB_NAME;
mergePullSub.DatabaseName = DB_NAME_SUB;
mergePullSub.LoadProperties();
mergePullSub.AltSnapshotFolder = "\\<server_name>\repldata";
mergePullSub.SynchronizationAgent.DistributorSecurityMode = SecurityMode.Standard;
mergePullSub.SynchronizationAgent.DistributorLogin = PC1_AC1_login;
mergePullSub.SynchronizationAgent.DistributorPassword = PC1_AC1_password;
mergePullSub.SynchronizationAgent.PublisherSecurityMode = SecurityMode.Standard;
mergePullSub.SynchronizationAgent.PublisherLogin = PC1_AC1_login;
mergePullSub.SynchronizationAgent.PublisherPassword = PC1_AC1_password;
mergePullSub.SubscriberSecurity.WindowsAuthentication = true;
syncAgent = mergePullSub.SynchronizationAgent;
syncAgent.ExchangeType = MergeExchangeType.Bidirectional;
// Start the Merge Agent Job.
try
{
syncAgent.Synchronize();
}
catch (Exception)
{
}
Can someone help me? Wher is the error?
Thank you very much