Asked by:
how do i manage the connection object from center

Question
-
User-1674296013 posted
hi I am using the "Application Name=MyAppName;" at connection string ,when I query the SELECT PROGRAM_NAME from sys.sysprocesses
its return more than row ,normally its return single row , hod do i manage.
Saturday, January 9, 2021 6:50 PM
All replies
-
User1120430333 posted
You need to be showing some code. How does anyone actually know what you are talking about?
Sunday, January 10, 2021 3:13 PM -
User-474980206 posted
The pseudo table is a list of all processes. If the client don’t have enough permission, they only see there own processes. If you want the process list tied to your current connection (though the app be be using pooling and have more than one) just filter by spid. Then limit to one row
select name from sys.sysprocesses where spid = @@spid fetch first 1 row only
Sunday, January 10, 2021 4:55 PM -
User-1674296013 posted
bruce (sqlwork.com)
The pseudo table is a list of all processes. If the client don’t have enough permission, they only see there own processes. If you want the process list tied to your current connection (though the app be be using pooling and have more than one) just filter by spid. Then limit to one row
select name from sys.sysprocesses where spid = @@spid fetch first 1 row only
hi , I already manage using sql query such as DISTINCT or GROUP BY
But I want to manage with connection object ,so I review some professional ERP program and query to sys.sysprocesses and than its seems single row , so I want to manage on single connection object , also my structure like below
public SqlConnection GetConnection() { var con=new SqlConnection(connectionstring) return con; } public void Do1() { var con=GetConnection(); con.Open(); //ExecuteCommand con.Close(); } public void Do2() { var con=GetConnection(); con.Open(); //ExecuteCommand con.Close(); } public void Do3() { var con=GetConnection(); con.Open(); //ExecuteCommand con.Close(); } Call Do1() with btnDo1 Call Do2() with btnDo2 Call Do3() with btnDo3
after do that ,when I query SELECT PROGRAM_NAME FROM sys.sysprocesses WHERE PROGRAM_NAME='MyAppName'
its seems like below.
MyAppName
MyAppName
MyAppNameSunday, January 10, 2021 7:57 PM -
User-474980206 posted
as I said thats correct. there is a row for every connection (client and server). your connection permission controls whether all are returned, or only the ones for the same user as the connection.
the result of you query shows there are 3 connection using the application name 'MyAppName'
if you displayed the spid you could use the spid to get more info about the connection.
note: with asp.net core you should be using the async versions of sql library call
Sunday, January 10, 2021 8:24 PM -
User-1674296013 posted
as I said thats correct. there is a row for every connection (client and server). your connection permission controls whether all are returned, or only the ones for the same user as the connection.
the result of you query shows there are 3 connection using the application name 'MyAppName'
if you displayed the spid you could use the spid to get more info about the connection.
note: with asp.net core you should be using the async versions of sql library call
hi,
I am testing a popular ERP program such as SAP and I clicked more than 10 buttons ,each button doing different task ,
after do this,its return single row when i query to PROGRAM_NAME on sys.sysprocess
Note :I know async ,I just want to give you a little demo
Sunday, January 10, 2021 8:38 PM -
User-474980206 posted
The program (SAP) you ran only opened one connection, your code opened 3. (Probably used connection pooling)
Monday, January 11, 2021 3:41 PM