我有一個應用程序,它使用SQL Server Express 2008中的linq-to-sql。當我在單獨的DAL項目中使用DBML文件並將它引用到我的Web項目,在執行SQL服務器顯示了這個錯誤:Asp.Net與SQL Server和Asp.net Linq應用程序
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)
但是,當我在我的web項目中使用DBML,調試是沒有任何問題。但在IIS在64位Windows 7我得到:
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
做這兩個錯誤有相同的原因是什麼?連接字符串不正確?
你的意思是,當我從應用程序讀取dbml文件時,從主web項目的dbml句柄?! connecttion字符串位於DAL項目的app.config中。 其他問題:...並且您的機器可以通過IIS機器訪問......這是怎麼回事? –
正在運行的應用程序(您的Web項目)的配置文件是在運行時讀取的文件。這就是連接字符串應該在的地方。第二個問題:檢查你是否可以在IIS機器的瀏覽器中「查看」你的機器。然後檢查您的Web應用程序在IIS中運行的帳戶是否對您的數據庫擁有足夠的權限。 –