gpt4 book ai didi

asp.net - 通过别名从本地 IIS7 连接到 SQL Server 时出错

转载 作者:行者123 更新时间:2023-12-04 02:57:11 25 4
gpt4 key购买 nike

只是想知道以前是否有人遇到过这个问题。有几个开发人员看过这个,但我们都无法弄清楚。

我有一个 ASP.NET Web 窗体应用程序使用 EF4 通过别名连接到 Sql Server 数据库。别名设置为指向我的机器名称(不是“.”或“本地”)。当我用 VS2012 运行它时,它工作正常。如果我将它部署到我的本地 IIS7 实例并尝试在浏览器中将其拉出,我会收到错误消息:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

我的连接字符串如下所示:

Data Source=aliasName;Initial Catalog=databaseName;Integrated Security=True;MultipleActiveResultSets=True

如果我更改连接字符串以便数据源是我的机器名而不是别名,它在 IIS7 中工作正常。因此,问题似乎出在别名上,并且仅在 IIS7 用完时才出现。

作为解决方法,我使用本地构建配置文件来部署不在本地使用别名的不同 web.config,但我真的很想弄清楚为什么它不起作用。

如有任何建议,我们将不胜感激。

最佳答案

检查 this ,具体来说:

使用 SQL Server 别名的先决条件

  1. 您必须愿意让您的客户端通过网络协议(protocol)连接到实例。当客户端和实例在同一系统上时,无法使用可用的共享内存连接。我为我的别名使用 TCP/IP 连接。

  2. 在托管 SQL Server 实例的系统上,您必须运行 SQL Server Browser 服务(这通常将“启动模式”设置为“自动”)。

  3. 在 64 位系统上,如果您同时拥有 32 位和 64 位客户端,则需要为 32 位和 64 位客户端创建别名。

关于asp.net - 通过别名从本地 IIS7 连接到 SQL Server 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16342274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com