关于asp.net:无法从SQL Server 2012获取数据

Cannot get data from SQL Server 2012

enter image description here

当我尝试登录我的网站时,发生错误。 我也尝试过运行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)

连接字符串

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


根据您的连接字符串,您正在尝试连接到名为SQLEXPRESS (metro)的SQL Server Express实例-这真的是您实例的实际名称吗?

通常,如果您不更改任何默认值,则仅为SQLEXPRESS,因此您的连接字符串应为

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

转到Start > Microsoft SQL Server > SQL Server xxxx > Configuration Tools > SQL Server Configuration Manager时,您可以看到拥有的SQL Server实例(以及它们的名称)-您将看到类似以下内容:

enter image description here

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