Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to run the following query ::

  FROM sys.dm_exec_requests S
  JOIN sys.dm_exec_sessions R ON r.session_id = s.blocking_session_id

It works when i run it in SQL Server Console.
But I haven't been able to do the same thru code. I am using the following connection string:

"Data Source=localhost\\sqlexpress;Initial Catalog=Master;Integrated Security = True"

Till now I have used sys and MsSQLSystemResource in the place of Master in the connection string ; But i am facing same error which says that there is problem connecting .. instance name could be wrong ..

i keep getting the following error

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)
share|improve this question
Data Source=(local)\sqlexpress

I assume the double \ was for escaping

share|improve this answer
yes it was ! shuldnt it be ? – Wildling Jun 2 '11 at 8:25
i didnt understand your answer btw. what are the braces trying to suggest ? is that the syntax ? – Wildling Jun 2 '11 at 8:27
That is the syntax for a local SQL Server install. – gbn Jun 2 '11 at 8:28
i am going for a remote connection. i have also gone for "Data Source=<machine name>\\sqlexpress;Initial Catalog=Master;Integrated Security = True" but even that dont work – Wildling Jun 2 '11 at 8:30
Can you add the exact error please? – gbn Jun 2 '11 at 8:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.