我能同步上的SQL Server 2008 R2 Express中的合并请求订阅 - 用C#以下位通过RMO - 没有SQL Server代理:
static void SynchronizeMergePullSubscriptionViaRMO()
{
// Define the server, publication, and database names.
string subscriberName = "WIN8CP\\SQLEXPRESS";
string publisherName = "WS2008R2_1";
string distributorName = "WS2008R2_1";
string publicationName = "TestMergePub2";
string subscriptionDbName = "TestSubDB1";
string publicationDbName = "AdventureWorksLT";
// Create a connection to the Subscriber.
ServerConnection conn = new ServerConnection(subscriberName);
MergePullSubscription subscription;
MergeSynchronizationAgent agent;
try
{
// Connect to the Subscriber.
conn.Connect();
// Define the pull subscription.
subscription = new MergePullSubscription();
subscription.ConnectionContext = conn;
subscription.DatabaseName = subscriptionDbName;
subscription.PublisherName = publisherName;
subscription.PublicationDBName = publicationDbName;
subscription.PublicationName = publicationName;
// If the pull subscription exists, then start the synchronization.
if (subscription.LoadProperties())
{
// Get the agent for the subscription.
agent = subscription.SynchronizationAgent;
// Set the required properties that could not be returned
// from the MSsubscription_properties table.
agent.PublisherSecurityMode = SecurityMode.Integrated;
agent.DistributorSecurityMode = SecurityMode.Integrated;
agent.Distributor = publisherName;
// Enable agent output to the console.
agent.OutputVerboseLevel = 4;
agent.Output = "C:\\TEMP\\mergeagent.log";
// Synchronously start the Merge Agent for the subscription.
agent.Synchronize();
}
else
{
// Do something here if the pull subscription does not exist.
throw new ApplicationException(String.Format(
"A subscription to '{0}' does not exist on {1}",
publicationName, subscriberName));
}
}
catch (Exception ex)
{
// Implement appropriate error handling here.
throw new ApplicationException("The subscription could not be " +
"synchronized. Verify that the subscription has " +
"been defined correctly.", ex);
}
finally
{
conn.Disconnect();
}
}
一个代码示例可以从下载MSDN Code Gallery。
这是一个非常好的问题。我花了一周的时间思考Express版(2012)SQL Server如何在没有SQL代理的情况下进行Pull复制。最后,我做了很多研究,但可以付出努力。 – Cheung 2013-08-23 09:02:56