2015-08-09 67 views
1

此问题已在堆栈溢出。但没有人解决我的问题。错误:26 - 错误定位服务器/实例指定(尝试很多事情,但找不到解决方案)

当我打开我的网页(对服务器我上传的网站),其中我使用下面的错误数据库连接来 - 搜索在谷歌

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

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)

,发现很多事情和应用它但没有人解决我的问题。

  1. Windows服务名为“SQL Server Browser”并启动服务(我启用了它)。

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

我的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中只会有变化,其余都是正确的。

+0

你的系统上有SQL Server Management Studio吗?我很想用它登录到SQL服务器。使用Windows凭据。 – DhruvJoshi

+0

Hi @DhruvJoshi。对不起,延迟回复。是的,它在Windows身份验证上正确登录。我在我的问题上添加了链接。检查它,它可以帮助你解决问题。 –

+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文件,你会得到解决。

相关问题