If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Limit current Users

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-05-03, 17:41
Tal_McMahon Tal_McMahon is offline
Registered User
 
Join Date: Jun 2003
Posts: 11
Limit current Users

Hello all I am trying to write an app that limits the concurrent users. I have not done this before in SQL as most of my programming has been stateless.

How do I connect to the DB at startup?

How do I count the current users?

thanks

tal
Reply With Quote
  #2 (permalink)  
Old 06-06-03, 05:58
Satya Satya is offline
Grand Poobah
 
Join Date: Aug 2002
Location: Scotland
Posts: 1,578
Refer to this Winnet Mag article.
__________________
--Satya SKJ
Microsoft SQL Server MVP
[IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]
Reply With Quote
  #3 (permalink)  
Old 06-06-03, 10:05
Tal_McMahon Tal_McMahon is offline
Registered User
 
Join Date: Jun 2003
Posts: 11
Thanks for the link. I Cannot use a Windows 2000 solution as I am not sure of the networks that my app will be running on. I was hoping to count the people logged into my SQL server.

tal
Reply With Quote
  #4 (permalink)  
Old 06-06-03, 10:06
Satya Satya is offline
Grand Poobah
 
Join Date: Aug 2002
Location: Scotland
Posts: 1,578
Then use SP_WHO2 from query analyzer
__________________
--Satya SKJ
Microsoft SQL Server MVP
[IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]
Reply With Quote
  #5 (permalink)  
Old 06-06-03, 10:10
Tal_McMahon Tal_McMahon is offline
Registered User
 
Join Date: Jun 2003
Posts: 11
I know about sp_Who, my problem is that I have always just connected to the database when I wanted to make a call in the following fasion:

Open connection
get data
Close connection

How can I open the connection for the entire application?

I would like to open a connection similar to the one that is opened when you launch Query analyzer.


thanks again

Tal
Reply With Quote
  #6 (permalink)  
Old 06-09-03, 06:57
Satya Satya is offline
Grand Poobah
 
Join Date: Aug 2002
Location: Scotland
Posts: 1,578
Keep the connection open all the times to the database may cause performance issues rather re-connecting from application code.

I don't know what is the reason behind to do so, but once you apply connection to the server it will not get disconnected until you specify disconnect method from the code. SQL Server doesn't disconnect the client connection deliberately.
__________________
--Satya SKJ
Microsoft SQL Server MVP
[IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]
Reply With Quote
  #7 (permalink)  
Old 06-09-03, 11:14
Tal_McMahon Tal_McMahon is offline
Registered User
 
Join Date: Jun 2003
Posts: 11
Quote:
Originally posted by Satya
Keep the connection open all the times to the database may cause performance issues rather re-connecting from application code.

I don't know what is the reason behind to do so, but once you apply connection to the server it will not get disconnected until you specify disconnect method from the code. SQL Server doesn't disconnect the client connection deliberately.

I am trying to only allow a licensed number of clients... I also want the connection to die if there is a hard close of the client.

How much of a hit is there if I keep the connection open at all times?

thanks again

tal
Reply With Quote
  #8 (permalink)  
Old 06-10-03, 06:17
Satya Satya is offline
Grand Poobah
 
Join Date: Aug 2002
Location: Scotland
Posts: 1,578
BTW what is the licensing mode currently on the server?

By any chance you cannot assign SQL to close the connection if the client disappers from the network. Until unless you restart the services the connection will be shown as sleeping status.

To know the performance bottlenecks you better deploy PERFMON and capture the counters.
__________________
--Satya SKJ
Microsoft SQL Server MVP
[IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]
Reply With Quote
  #9 (permalink)  
Old 06-10-03, 08:08
Paul Young Paul Young is offline
Registered User
 
Join Date: Feb 2002
Location: Houston, TX
Posts: 809
Tal, SQL Server & NT handle license complience rather well. Could you explain your situation a little bit more?

Have you thought of writing a stored procedure to check counts and idle connections? You could then schedule the sp to run at regular intervals. if you were out of complience on licenses or found idle connections you could send an e-mail or remidy the problem.
__________________
Paul Young
(Knowledge is power! Get some!)
Reply With Quote
  #10 (permalink)  
Old 06-10-03, 10:39
Tal_McMahon Tal_McMahon is offline
Registered User
 
Join Date: Jun 2003
Posts: 11
O.k. Maybe I was not specific enoughso here is the scenario:

I work for a small company that sells a piece of software that is backended on a SQL server. Currently, the software is sold on a per client basis. We would like to make the software licensed on a total concurrent user basis.

Currently, I open connection, do data stuff, close connection.

This obviousely would not work as the connections are only open for a few seconds at a time.

My plan is Open a connection
Count Currently open connections

return false if the Licenses are all filled up
Message the user that the licensed copies are in use
Close the Connection

-OR-

Return true if there is a connection available
Leave the connection open until application close


Will this Scenario Work?

tal
Reply With Quote
  #11 (permalink)  
Old 06-10-03, 13:33
Paul Young Paul Young is offline
Registered User
 
Join Date: Feb 2002
Location: Houston, TX
Posts: 809
Tal, IMNSHO, I think you are on the right track with your last post. I think keeping a connection open for a short period of time COULD be a good thing.

I would hold the connection open for as long as needed and then close the connection. This allows more users to use a smaller number of licenses, just don't close a connection before your work is done!
__________________
Paul Young
(Knowledge is power! Get some!)
Reply With Quote
  #12 (permalink)  
Old 06-10-03, 13:49
Tal_McMahon Tal_McMahon is offline
Registered User
 
Join Date: Jun 2003
Posts: 11
I want to plug up the licenses, We sell them for a few hundred a piece. what are the drawbacks to leaving an ADO connection open for 30 minutes?

tal
Reply With Quote
  #13 (permalink)  
Old 06-10-03, 14:13
Paul Young Paul Young is offline
Registered User
 
Join Date: Feb 2002
Location: Houston, TX
Posts: 809
To my knowledge, none. If you need to be connected for 30 min. that's what you need to do. You do take a memory hit for each connection but an idle connection isn't going to hurt your server.
__________________
Paul Young
(Knowledge is power! Get some!)
Reply With Quote
  #14 (permalink)  
Old 06-10-03, 14:19
Tal_McMahon Tal_McMahon is offline
Registered User
 
Join Date: Jun 2003
Posts: 11
Cool Thats what I thought....
thanks

tal
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On