我想运行以下查询::
SELECT S.*
FROM sys.dm_exec_requests S
JOIN sys.dm_exec_sessions R ON r.session_id = s.blocking_session_id
当我在 SQL Server 控制台中运行它时,它可以工作。
但我无法通过代码执行相同的操作。我使用以下连接字符串:
"Data Source=localhost\\sqlexpress;Initial Catalog=Master;Integrated Security = True"
到目前为止,我已经在连接字符串中使用sys
and代替了 Master ;但我遇到了同样的错误,提示连接时出现问题...实例名称可能有误...MsSQLSystemResource
我一直收到以下错误
System.Data.SqlClient.SqlException (0x80131904): 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=(local)\sqlexpress
我认为替身\
是为了逃跑