PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > comp.db.ms-sqlserver > How to control number of users in a database?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
How to control number of users in a database?

Réponse
 
LinkBack Outils de la discussion
Vieux 07/10/2008, 14h06   #1
kai
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to control number of users in a database?

Hi,
I use VB 2008 as front end, SQL Server 2005/2008 as back end, I want
control number of cucurrent users log on to the database, I am trying to use
a stored procedure, but it did not work. Is this possible? Please .

Thanks

Kai



  Réponse avec citation
Vieux 07/10/2008, 23h32   #2
Erland Sommarskog
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to control number of users in a database?

kai (kailiang@bellsouth.net) writes:
> I use VB 2008 as front end, SQL Server 2005/2008 as back end, I want
> control number of cucurrent users log on to the database, I am trying to
> use a stored procedure, but it did not work. Is this possible? Please
> .


If you actually mean *database* I don't think there is a foolproof
way to do this. You could set up a logon trigger that checks the current
database and compares this the number of connections active in the database,
and if the magic number is exceeded raises an error.

However, if the user would first connect to, say, the master database,
then issue a USE for the database in questions, in which case your trigger
wouldn't catch him.

On the other hand, if you wish to restrict the number of connections to
the entire *server*, this is very easy:

EXEC sp_configure 'show advanced options', 1
RECONFIGURE
EXEC sp_configure 'user connections', 50
RECONFIGURE

I would advice you to be very careful with this. If your application
uses multiple connections, you may find that 50 connections scales down
to a maximum of 10 users.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

  Réponse avec citation
Vieux 10/10/2008, 05h19   #3
Andy M
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to control number of users in a database?

On Oct 7, 8:06am, "kai" <kaili...@bellsouth.net> wrote:
> Hi,
> I use VB 2008 as front end, SQL Server 2005/2008 as back end, I want
> control number of cucurrent users log on to the database, I am trying to use
> a stored procedure, but it did not work. Is this possible? Please .
>
> Thanks
>
> Kai


Hi Kai,

As part of your application's login, you might want to try querying
sys.sysprocesses. In SQL 2005/2008, this is a system view that shows
information on all current connections to your SQL Server Instance.
http://msdn.microsoft.com/en-us/library/ms179881.aspx

When your VB app connects to the database, you are able to supply the
program_name as part of the connection string-- this application name
is available in sysprocesses. I presume that your interest in
counting connections is so that you can control licensing of your
application. You can use this basic query to count connections by
your application:

SELECT COUNT(*)
FROM master.dbo.sysprocesses
WHERE program_name = 'MyApplication'

If your application creates multiple connections to the database, you
might end up counting that single user more than once. If that's the
case, you might need to try a variation utilizing other columns in
sysprocesses.

SELECT COUNT(DISTINCT hostname)
FROM master.dbo.sysprocesses
WHERE program_name = 'MyApplication'

SELECT COUNT(DISTINCT nt_username)
FROM master.dbo.sysprocesses
WHERE program_name = 'MyApplication'
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h18.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11043 seconds with 11 queries