无法从 SQL Server 2012 获取数据

Cannot get data from SQL Server 2012

当我尝试登录我的网站时,出现错误。我也尝试使用 运行 SQL 服务。

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)

连接字符串

Data Source=.\SQLEXPRESS (metro);Initial Catalog=metrodb;Integrated Security=True

根据您的连接字符串,您正在尝试连接到名为 SQLEXPRESS (metro) 的 SQL 服务器 Express 实例 - 是 really 你的实例的实际名称??

通常,如果您不更改任何默认值,它只是 SQLEXPRESS,因此您的连接字符串应该是

Data Source=.\SQLEXPRESS;Initial Catalog=metrodb;Integrated Security=True

当您转到 Start > Microsoft SQL Server > SQL Server xxxx > Configuration Tools > SQL Server Configuration Manager 时,您可以看到您拥有的 SQL 个服务器实例(以及它们的名称)- 您会看到类似这样的内容:

您应该看到至少一个已启动的 SQL Server (instance name) 服务 - 括号中的名称是您的 实例名称 MSSQLSERVER 指的是默认值,未命名的实例)。那么这在您的案例中说明了什么?