2012-10-22 61 views
2

我使用了其他人制作的舊軟件,該軟件需要連接到擴展名爲.mdf的數據庫。錯誤26無法連接到數據庫

但是當我運行該軟件時,我有一個error 26。我明顯檢查過Google,看來主要的問題是防火牆。但如果我禁用它,問題不會消失。

這裏是代碼連接數據庫:

DataClasses1DataContext db = new DataClasses1DataContext(Environment.CurrentDirectory + "\\bddgestionvin.mdf"); 

我注意到,當我嘗試將數據庫與DataContext類將其與同error 26也無法連接。 (見下附截圖)

此類使用的字符串連接:

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\bddgestionvin.mdf;Integrated Security=True;Connect `Timeout=30;User Instance=True` 

我知道我有點含糊,但我從來沒有這樣的東西(連接到一個數據庫中密度纖維板)而代碼不是我的,請隨時詢問進一步的解釋/代碼。歡迎任何幫助!

P.S的錯誤消息是

SqlException was unhandled 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)

(很抱歉的法國軟件)

+0

[無法連接到SQL Express「錯誤的可能重複:26-錯誤定位服務器/實例指定)](http://stackoverflow.com/questions/6466974/unable-to-connect-to-sql-express-error-26-error-locating-server-instance-speci) –

+0

是bddgestionvin .mdf在執行應用程序目錄中?sql連接表示在應用程序目錄中自動附加mdf文件 –

+0

是的,他在bin/debug文件夾。是的,我知道有很多的話題,但沒有人幫助我,這就是爲什麼我開了一個新的話題 – Edelweiss

回答

1

您好我不知道你可能會看到這些步驟。確保這些步驟應該通過。

The reason that we get this error message is the client stack could not receive SSRP response UDP packet from SQL Browser. It's easy to isolate the issue. Here are the steps:

1) Make sure your server name is correct, e.g., no typo on the name.

2) Make sure your instance name is correct and there is actually such an instance on your target machine. [Update: Some application converts \ to . If you are not sure about your application, please try both Server\Instance and Server\Instance in your connection string]

3) Make sure the server machine is reachable, e.g, DNS can be resolve correctly, you are able to ping the server (not always true).

4) Make sure SQL Browser service is running on the server.

5) If firewall is enabled on the server, you need to put sqlbrowser.exe and/or UDP port 1434 into exception.

您可以閱讀here

更多你也可以嘗試PortQry和驗證您的防火牆沒有阻止SQL瀏覽器UDP數據包

同時建立了發生與網絡相關的或特定於實例的錯誤連接到SQL Server。 Failed to establish a connection with SQL Server.

服務器未找到或無法訪問。 May be server is stopped, you don't have permission to access the server, or the instance name is not correct .

驗證實例名稱是否正確,並且SQL Server配置爲允許遠程連接。

Please goto SSMS and try connecting the server. Verify the SQL Server is running and your account is configured to access the service.

(提供者:SQL網絡接口,錯誤:26 - 錯誤定位指定的服務器/實例)

感謝

+0

我在本地存儲的數據庫中運行此軟件,是否也需要檢查所有DNS /服務器步驟? – Edelweiss

+0

從這個圖像我可以看到你正在使用'./SQLEXPRESS'。通常這意味着服務器將是本地主機,實例名稱爲SQLEXPRESS。您可以使用SSMS連接SQL Server嗎? – kbvishnu

+0

我不知道我是否可以使用SSMS連接,我會看看並給你提供關於它的消息 – Edelweiss

相關問題