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

前端之家收集整理的这篇文章主要介绍了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协议

猜你在找的asp.Net相关文章