Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to run the following query ::

SELECT S.*
  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

1 Answer 1

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

 
discard

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.