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
exec sp_who2
B) my app executed from location2
exec sp_who2
sorry for my english.
thanks in advance.
Wouldn't it be easier to simply have a table where you add a record when the program starts and remove it when the program exits? Keeping a connection to SQL Server open all the time is quite expensive.
Technically, someone could come along a delete the record and start up a new instance, but obviously if they do that then the first instance is going to stop working (assuming it checks for the presense of it's own record every now and then).
Connection pooling keeps the connection alive:
http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With