错误:26 - 找到指定的服务器/实例时出错(尝试了许多但无法找到解决方案)

时间:2015-08-09 11:42:21

标签: sql-server database-connection

这个问题已经在Stack Overflow上了。但没人能解决我的问题。

当我打开我的网页(在我上传的服务器上的网站上)我正在使用数据库连接时,出现错误 -

http://puneetchawla-001-site1.smarterasp.net/blog.aspx

  

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供程序:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错)

在Google上搜索并找到了许多内容并应用了它,但没有人解决我的问题。

  1. Windows服务称为" SQL Server Browser"并启动服务(我启用了它)。

  2. 启用传入端口TCP 1433(我已经这样做了。)

  3. 我的web.config文件 -

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    
        <connectionStrings>
    <add name="myWebsite" connectionString="Data Source=.\sqlexpress;Initial Catalog=myWebsite;Integrated Security=True; " providerName="System.Data.SqlClient" />  </connectionStrings>
    
      <system.web>
       <customErrors mode="Off" />
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" />
      </system.web>
    </configuration>
    

    我上传了我的网站 - http://www.smarterasp.net

    及其MSSQL的连接字符串示例低于 -

    "Data Source=SQL5014.Smarterasp.net;Initial Catalog=DB_9D58DA_myWebsite;User Id=DB_9D58DA_myWebsite_admin;Password=YOUR_DB_PASSWORD;"
    

    我根据我们的样本对web.config进行了更改,但没有得到解决方案。

    我认为,web.config只会有变化,其余都是正确的。

1 个答案:

答案 0 :(得分:0)

您尚未在web.config文件中编写连接字符串(如示例中所指定)。 您的web.config文件应该像

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <connectionStrings>
<add name="myWebsite" connectionString="Data Source=SQL5014.Smarterasp.net;Initial Catalog=DB_9D58DA_myWebsite;User Id=DB_9D58DA_myWebsite_admin;Password=YOUR_DB_PASSWORD;" />  </connectionStrings>

  <system.web>
   <customErrors mode="Off" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
</configuration>

只需更改您的web.config文件即可获得解决方案。

相关问题