2015-08-09 66 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文件,你會得到解決。

相關問題