asp.net – SQL网络接口,错误:26 – 定位服务器/实例指定错误

我有一个很大的问题,我正在努力解决几天,但我无法做到这一点,所以我需要你的帮助。我在asp.net 4.0中有一个Web应用程序,我实现了自定义成员资格和角色提供程序。当我打开应用主页时,它连接到数据库并检索一些信息。还有一个登录表单,当我登录时通过数据库验证用户,并将我重定向到保留的页面,但是出现这个错误:

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: 26 – Error Locating Server/Instance
Specified)

描述:

An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about
the error and where it originated in the code.

例外详情:

System.Data.SqlClient.SqlException: 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: 26
– Error Locating Server/Instance Specified)

源错误:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

我尝试了很多东西,我在stackoverflow中发现了一些解决方案,但没有任何工作。这是我的连接字符串:

<connectionStrings>
  <clear/>
  <remove name="LocalSqlServer"/>
     <add name="LocalSqlServer" connectionString="Data Source=MSSQL2008-1;Initial Catalog=agency;
        Integrated Security=False;User ID=adis_agency;Password=niarda2012;Connect Timeout=180;Encrypt=False;
        Packet Size=4096" providerName="System.Data.SqlClient" />
     <add name="AgencyConn" connectionString="Data Source=MSSQL2008-1;Initial Catalog=agency;
        Integrated Security=False;User ID=adis_agency;Password=niarda2012;Connect Timeout=180;Encrypt=False;
        Packet Size=4096" providerName="System.Data.SqlClient"/>
</connectionStrings>

以下也是会员和角色管理器的web.config部分:

<membership defaultProvider="AuthProvider">
  <providers>
    <clear/>
      <add name="AuthProvider" type="AuthenticationProvider" applicationName="~/Reserved/" connectionStringName="AgencyConn"/>
  </providers>
</membership>
<roleManager enabled="true" defaultProvider="MyRoleProvider">
  <providers>
    <clear/>
      <add name="MyRoleProvider" type="RoleAccessProvider" connectionStringName="AgencyConn"/>
  </providers>
</roleManager>

请问有谁能帮忙弄清楚出了什么问题?

如果要从Windows机器A连接到Windows机器B(已安装SQL Server的服务器),并且遇到此错误,则需要执行以下操作:

在机器B上:

1.打开名为“SQL Server Browser”的Windows服务并启动服务

2.)在Windows防火墙中,启用传入端口UDP 1434(如果机器A上的SQL Server Management Studio正在连接或机器A上的程序正在连接)

3.)在Windows防火墙中,启用传入端口TCP 1433(如果有telnet连接)

4.)在SQL Server配置管理器中,为端口1433启用TCP / IP协议

http://stackoverflow.com/questions/13754563/sql-network-interfaces-error-26-error-locating-server-instance-specified

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:asp.net – SQL网络接口,错误:26 – 定位服务器/实例指定错误