I was getting Instance Failure when connecting to my SQL Server Express 2005 Database in my C# ASP.NET application. Very weird.
在C#ASP.NET应用程序中连接到SQL Server Express 2005数据库时,出现实例故障。 很奇怪。
<connectionStrings>
<add name="NorthwindConnString"
connectionString="Data Source=.\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
Trial and error just taught me that the problem was "Data Source=.\\SQLEXPRESS;" - It's the double \\. That's an escape sequence in C#. Everything worked when I switched the connection string to .\SQLEXPRESS.
反复试验告诉我,问题出在“数据源=。\\ SQLEXPRESS;”。 -这是双\\。 这是C#中的转义序列。 当我将连接字符串切换为。\ SQLEXPRESS时,一切正常。
翻译自: https://www.hanselman.com/blog/fixing-instance-failure-when-connecting-to-sql-server-2005-express