1

试图找出SQL Server Express数据库的正确连接字符串。尝试将我的应用程序发布到IIS并在发布到我的托管站点之前进行测试。SQL Server Express连接字符串错误

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)

我开始here也使用connectionstrings.com。我也开始阅读使用SQL Server精简文章here

使用此连接字符串

Data Source=.\\SQLExpress;AttachDbFilename=H:\DB\Guestbook.sdf;Integrated Security=True 

我得到上述错误部署asp.net应用

此连接字符串

<add name="DefaultConnection" 
    connectionString="Data Source=.\SQLEXPRESS;Integrated Security=SSPI; database=Guestbook; AttachDBFilename=|DataDirectory|Guestbook.sdf" 
    providerName="System.Data.SqlClient" />` 

抛出信任级别错误。我已经更改为中等和完整,仍然得到两个错误之一。

我试过了几个不同的字符串的变体,没有运气。

感谢

回答

0

请验证SQL服务正在SERVICES.MSC开始,使用与主机名EJ完整的实例:主机名\ SQLEXPRESS

0

文件扩展名表示,这是不是一个SQL Server Express数据库,所以你必须使用:

Data Source=<Full path to file> 

Data Source=|DataDirectory|Guestbook.sdf