【问题标题】:Can't connect to SQL Server from asp.net application无法从 asp.net 应用程序连接到 SQL Server
【发布时间】:2023-03-20 09:58:01
【问题描述】:

您好,我想在 IIS 服务器上发布我的应用程序。

首先我在我的 sql server 中创建一个数据库,并将我需要的所有数据放在上面。

然后我更新我的web.config 以使用新的远程数据库。不幸的是我得到了一个错误

连接字符串:

<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=IntranetDatabase;Data Source=SRVDEV2010\SRVDEV2010" />

堆栈跟踪:

 [SqlException (0x80131904): 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: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]

我检查了我是否可以远程访问数据库。我创建了一个udl文件来验证我的connectionstring,结果如下。

我不知道为什么 udl 文件可以连接,但我的应用程序却不能。任何帮助表示赞赏

【问题讨论】:

    标签: asp.net sql-server connection-string


    【解决方案1】:

    应用程序池配置为在哪个用户下运行?您正在使用 Windows 身份验证,这意味着您的 IIS 应用程序池应配置为在有权访问数据库的用户下运行。

    【讨论】:

    • 我的应用程序位于使用 NetworkService 进行身份识别的池下,我认为问题不存在,因为我在同一个池下还有另一个应用程序,它运行良好。
    • 那么 UDL 在你的 windows 用户下运行,尝试将应用程序池设置为你的本地 windows 用户。
    • 你能给我更多的细节吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-19
    • 2021-06-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多