简体   繁体   English

实体Framewok-基础提供程序在打开时失败-SQL

[英]Entity Framewok - The underlying provider failed on Open - SQL

I have two small web pages for a proyect in a server, they were working with no problems, but suddenly when I entered my login and password, I got an error message "The underlying provider failed on Open". 我在服务器中有两个用于proyect的小网页,它们没有任何问题,但是突然当我输入登录名和密码时,我收到一条错误消息“底层提供程序在打开时失败”。

I edited the code so I can get the Inner Exception Message which was "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)". 我对代码进行了编辑,以便获得内部异常消息,该消息是“与SQL Server建立连接时发生了与网络相关或特定于实例的错误。找不到服务器或无法访问该服务器。请验证实例名称是否正确。并且该SQL Server已配置为允许远程连接。(提供者:命名管道提供程序,错误:40-无法打开与SQL Server的连接)”。

When I run the application within Visual Studio, using the servers connection string, everything works correctly, and I even can access the database from other applications in another server, so SQL is accepting remote connections. 当我在Visual Studio中使用服务器连接字符串运行应用程序时,一切正常,甚至可以从另一台服务器中的其他应用程序访问数据库,因此SQL接受远程连接。

The problem is that I cant access the database from the applications that are in the same server as my SQL database. 问题是我无法从与SQL数据库位于同一服务器上的应用程序访问数据库。 This is a new issue, as they have been running for months and they suddenly marked this error today. 这是一个新问题,因为它们已经运行了几个月,今天却突然标记了此错误。

In Visual Studio, unless you have an explicit SQL User Name and password in the connection string, the connection will be as you. 在Visual Studio中,除非连接字符串中有明确的SQL用户名和密码,否则连接将保持不变。 Under IIS it will be as the IIS worker process. 在IIS下,它将作为IIS工作进程。 Assuming you're using integrated security, your app then wouldn't be able to connect to the database unless the IIS AppPool Identity is a user with access to the database on SQL Server. 假设您使用的是集成安全性,则您的应用程序将无法连接到数据库,除非IIS AppPool身份是有权访问SQL Server上的数据库的用户。 In this case, the fix is to create an SQL account for the site to use with the least privileges required for the site to work and put those in your connection string. 在这种情况下,解决方法是为网站创建一个SQL帐户,以使其具有网站正常运行所需要的最少特权,并将这些特权放在连接字符串中。

Alternatively, it may be that certain protocols are not configured (named pipes, remote connection etc.) in the SQL Server surface area configuration. 或者,可能是在SQL Server外围应用配置中未配置某些协议(命名管道,远程连接等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM