根据 Microsoft 的说法,SQL Server 2008 Express 应该能够作为拉取订阅者参与合并复制。至少对于 RMO 对象来说是这样。
- http://msdn.microsoft.com/en-us/library/ms147890.aspx http://msdn.microsoft.com/en-us/library/ms147890.aspx
- http://msdn.microsoft.com/en-us/library/ms151819.aspx http://msdn.microsoft.com/en-us/library/ms151819.aspx
但其他变体也应该可以使用。
但是,我们无法在客户端(运行 SQL Server 2008 Express)上启动 SQL Server 代理。这似乎是一个常见问题,据我所知,尚未解决。
我是否正确地认为 SQL Server 2008 Express 实际上不支持合并(拉取)订阅?有人成功使用过这项技术吗?我认为微软声称它可以正常工作是非常严重的,尽管事实并非如此。
我希望有人有这方面的经验!
我能够在 SQL Server 2008 R2 Express 上同步合并拉取订阅(无需 SQL Server 代理),通过 RMO 使用以下 C# 代码:
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 代码库 http://code.msdn.microsoft.com/SQL-Server-Express-05c73322.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)