sql server replication:
Hi. I've looked all over MSDN, newsgroups and the web but I can't find
the answer to a problem that I am having.
The application that I am working on used both transactional and merge
replication. I want to avoid hard coding passwords into an application
that kicks off the pull replication on the client machine.
The client machines are all using SQL Server 2005 Express. The other
machine is running SQL Server Standard. The passwords and login details
are specified in the subscription properties in the Management Studio.
A fragment of the code is posted below. The transactional
sychronization works fine without having to specify any passwords -
however the merge replication does not work if both of the passwords
are not specified.
private void SynchButton_Click(object sender, EventArgs e)
{
// Set up the subscriber connection details.
subscriberConnection = new
ServerConnection(subscriberName);
try
{
// Connect to the Subscriber.
subscriberConnection.Connect();
// Do the transactional subscription synchronisation
independantly of the
// merge subscription replication.
try
{
transPullSubscription = new
TransPullSubscription(subscriptionDbName,
publisherName,
publicationDbName,
transPublicationName,
subscriberConnection);
// If the pull subscription and the job exists,
start the agent job.
if (transPullSubscription.LoadProperties() &&
transPullSubscription.AgentJobId != null)
{
TransSynchronizationAgent transSyncAgent =
transPullSubscription.SynchronizationAgent;
transSyncAgent.Synchronize();
}
else
{
}
}
catch (Exception ex)
{
}
// Do the merge subscription synchronisation
independantly of the
// transactional subscription replication.
try
{
// Set up the subscription details for the merge
subscription (bi-directional data)
mergePullSubscription = new
MergePullSubscription(subscriptionDbName,
publisherName,
publicationDbName,
mergePublicationName,
subscriberConnection);
// If the pull subscription and the job exists,
start the agent job.
if (mergePullSubscription.LoadProperties() &&
mergePullSubscription.AgentJobId != null)
{
MergeSynchronizationAgent mergeSyncAgent =
mergePullSubscription.SynchronizationAgent;
mergeSyncAgent.DistributorPassword =
"<<password>>";
mergeSyncAgent.PublisherPassword =
"<<password>>";
mergeSyncAgent.Synchronize();
}
etc etc..
Any help or suggestions will be greatly appeciated. Thanks.