Spike UK
asked on
Counting connections to SQL Server through C#
I am trying to determine the number of to a SQL Server database through a website written in C#.
I can correctly determine the number of connections using the following script through MS SQL Server Management Studio:
SELECT count(spid) as NoOfConnections FROM master.dbo.sysprocesses
(I intend to filter on web connections, but I want to keep it simple for purposes of the question)
This brings back the correct number.
However, when I run it through the website, it always returns just one connection.
I have checked the C# code is correct by querying another set of data on another table- it works fine.
The connection string I am using is:
"Data Source=.\\SQLEXPRESS;Initi al Catalog=myDB;Persist Security Info=True;User ID=myid;Password=mypwd"
I can correctly determine the number of connections using the following script through MS SQL Server Management Studio:
SELECT count(spid) as NoOfConnections FROM master.dbo.sysprocesses
(I intend to filter on web connections, but I want to keep it simple for purposes of the question)
This brings back the correct number.
However, when I run it through the website, it always returns just one connection.
I have checked the C# code is correct by querying another set of data on another table- it works fine.
The connection string I am using is:
"Data Source=.\\SQLEXPRESS;Initi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect Solution- well explained
ASKER