简体   繁体   English

SQL Server Express连接字符串错误

[英]SQL Server Express connection string error

Trying to figure out the correct connection string for a SQL Server Express database. 尝试找出SQL Server Express数据库的正确连接字符串。 Trying to publish my app to IIS and test before publishing to my hosting site. 尝试将我的应用程序发布到IIS并进行测试,然后再发布到我的托管站点。

A network-related or instance-specific error occurred while establishing a connection to SQL Server. 建立与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. 验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (提供者:SQL网络接口,错误:26-指定服务器/实例时出错)

I started here and also used connectionstrings.com . 我从这里开始,也使用connectionstrings.com I also started reading the deploy asp.net app using SQL Server Compact article here 我也开始在这里阅读使用SQL Server Compact的deploy asp.net应用程序

Using this connection string 使用此连接字符串

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

I get the above error 我收到上述错误

This connection string 此连接字符串

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

throws a trust level error. 引发信任级别错误。 I've changed to medium and full and still get one of the two errors. 我已更改为中等和完全状态,但仍然遇到两个错误之一。

I've tried a variation of a few different strings with no luck. 我尝试了几种不同的字符串的变体,但是没有运气。

Thanks 谢谢

请验证SQL服务已在services.msc中启动,并使用具有主机名ej的完整实例:HOSTNAME \\ SQLEXPRESS

The file extension indicates that this is not a SQL Server Express database, so you must use: 文件扩展名表示这不是SQL Server Express数据库,因此您必须使用:

Data Source=<Full path to file>

or 要么

Data Source=|DataDirectory|Guestbook.sdf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM