How can maintain a SqlConnection open always

Posted by Salvador on Stack Overflow See other posts from Stack Overflow or by Salvador
Published on 2010-03-16T03:29:09Z Indexed on 2010/03/16 7:26 UTC
Read the original article Hit count: 430

Filed under:
|
|
|

How can maintain a SqlConnection (or using another component) open (connected) always during the execution of my .Net app?

I need this because my app needs to detect using this commnad

 exec sp_who2 

how many instances of my app are connected to mydatabase, to restrict the access (license control).

example

A) my app executed from location1

  1. check the number of my apps connected to the sql server using exec sp_who2
  2. if the number of my applications < MaxLicencesConnected then start my app and open a sqlconnection

B) my app executed from location2

  1. check the number of my apps connected to the sql server using exec sp_who2
  2. if the number of my applications >= MaxLicencesConnected then close my application

sorry for my english.

thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms