2010-02-16 76 views
1

我有一个SQL Server 2005框设置合并复制到SQL Server CE 3.0。出版物,出版商,分销商和IIS都已经建立。SQL Server复制错误

在我的申请,我尝试使用下面的代码来同步数据库:

//TODO: Change for production 
//*************************** 
string localDBPath = @"C:\Documents and Settings\Robert\Desktop\MyDB.sdf"; 
//*************************** 

SqlCeReplication replicator = new SqlCeReplication(); 
replicator.InternetUrl = "http://myWebServer/sqlcesa30.dll"; 
replicator.Publisher = "mySqlServer"; 
replicator.PublisherDatabase = "myDatabase"; 
replicator.PublisherSecurityMode = SecurityType.NTAuthentication; 
replicator.Publication = "myPublication"; 
replicator.Subscriber = Dns.GetHostName(); 
replicator.SubscriberConnectionString = @"Data Source=" + localDBPath; 

try 
{ 
    // Check if the database file already exists 
    if (!System.IO.File.Exists(localDBPath)) 
    { 
     // Add a new subscription and create the local database file 
     replicator.AddSubscription(AddOption.CreateDatabase); 
    } 

    // Transfer the initial snapshot of data if this is the first time this is called. 
    // Subsequent calls will transfer only the changes to the data. 
    replicator.Synchronize(); 
} 
catch (SqlCeException ex) 
{ 
    // Display any errors in message box 
    MessageBox.Show(ex.Message); 
} 
finally 
{ 
    // Dispose of the SqlCeReplication object, but don't drop the subscription 
    replicator.Dispose(); 
} 

不幸的是,该代码将失败,并出现以下错误消息“replicator.Synchronize”行:

未能通过提供的连接信息连接到SQL Server。 SQL Server不存在,访问被拒绝,因为IIS用户不是SQL Server上的有效用户,或者密码不正确。

这个错误信息对我来说并不是很清楚,而且我没有足够的空间去寻找原因了。有任何想法吗?

回答

1

确保代理帐户在所有框上都是相同的用户和密码。

确保您正在调用正确的实例。

确保在涉及的所有机器上启动代理。

检查所有服务器上的sql事件日志,看看哪个错误发生,这也可能缩小问题的范围。

您还可以检查是为了确保你有设置正确:

http://msdn.microsoft.com/en-us/library/aa454892.aspx

这里

同样的问题,他必须正确添加实例名称:

http://bytes.com/topic/sql-server/answers/611761-merge-replication-error-failure-connect-sql-server-provided-connection

检查这些了太:

http://support.microsoft.com/kb/314783

http://support.microsoft.com/kb/319723

http://msdn2.microsoft.com/en-us/library/ms172357.aspx

再次确保您的实例是正确的: repl.Publisher = “macnine名\实例名”

您还可以看看通过这个博客:

http://blogs.msdn.com/sql_protocols/archive/2005/09/28/474698.aspx

0

消息来自您的IIS复制插件:// MyWebServer的/ sqlcesa30.dll。当它试图连接到发布者时,它找不到它。发布者被命名为'mySqlServer',但显然myWebServer无法访问它。这可能是名称问题(拼写错误),防火墙问题(SQL端口被阻止),IPSEC问题,配置问题(SQL不会监听远程连接)等等。遵循myWeServer和mySqlServer之间的常规SQL Server连接故障排除步骤。