【问题标题】:SQL Server Replication ErrorSQL Server 复制错误
【发布时间】:2010-02-16 18:36:18
【问题描述】:

我有一个 SQL Server 2005 机器,用于合并复制到 SQL Server CE 3.0。出版商、出版商、发行商、IIS均已设置完毕。

在我的应用程序中,我尝试使用以下代码同步数据库:

//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 上的有效用户,或者密码不正确。

这个错误信息对我来说不是很清楚,我没有地方去寻找它的原因。有什么想法吗?

【问题讨论】:

    标签: c# sql-server iis replication sql-server-ce


    【解决方案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-name\instance-name"

    你也可以通过这个博客看看:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-10-07
        • 1970-01-01
        • 2013-09-26
        • 1970-01-01
        • 2011-06-24
        • 1970-01-01
        • 2014-05-20
        • 1970-01-01
        相关资源
        最近更新 更多