SQL Server 复制错误

发布于 2024-08-21 13:22:21 字数 1605 浏览 7 评论 0原文

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

这个错误消息对我来说不是很清楚,我已经没有地方可以查找其原因了。有什么想法吗?

I have a SQL Server 2005 box set up for merge replication to SQL Server CE 3.0. The publication, publisher, distributor and IIS have all been set up.

In my application, I attempt to sync the databases using the following code:

//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();
}

Unfortunately, this code fails at the "replicator.Synchronize" line with the following error message:

Failure to connect to SQL Server with provided connection information. SQL Server does not exist, access is denied because the IIS user is not a valid user on the SQL Server, or the password is incorrect.

This error message is not very clear to me and I am running out of places to look for the cause of this. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡莣 2024-08-28 13:22:21

确保所有盒子上的代理帐户的用户名和密码都相同。

确保您调用正确的实例。

确保代理已在所有涉及的计算机上启动。

检查所有服务器上的 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

Make sure the agent account is the same user and password on all boxes.

Make sure you are calling the right instances.

Make sure agent is started on all machines involved.

Check the sql event logs on all servers and see which is giving the error, this may also narrow the issue down.

You can also check this to make sure you have setup correctly:

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

Same issue here he had to add the instance name correctly:

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

Check these out too:

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

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

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

again make sure you instances are correct:
repl.Publisher = "macnine-name\instance-name"

You can also take a look through this blog:

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

羁客 2024-08-28 13:22:21

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

the message comes from your IIS replication plug-in: //myWebServer/sqlcesa30.dll. When it tries to connect to the publisher, it cannot find it. The publisher is named 'mySqlServer', but apparently it cannot be reached by myWebServer. This can be a name issue (a typo), a firewall issue (SQL port blocked), an IPSEC issue, a configuration issue (SQL is not listenning for remote connections) and so on. Follow normal SQL Server connectivity troubleshooting steps between myWeServer and mySqlServer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文