473,750 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to control number of users in a database?

kai
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 help.

Thanks

Kai

Oct 7 '08 #1
2 8647
kai (ka******@bells outh.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
help.
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, es****@sommarsk og.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

Oct 7 '08 #2
On Oct 7, 8:06*am, "kai" <kaili...@bells outh.netwrote:
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 help.

Thanks

Kai
Hi Kai,

As part of your application's login, you might want to try querying
sys.sysprocesse s. 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.sysp rocesses
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.sysp rocesses
WHERE program_name = 'MyApplication'

SELECT COUNT(DISTINCT nt_username)
FROM master.dbo.sysp rocesses
WHERE program_name = 'MyApplication'
Oct 10 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4027
by: pnp | last post by:
Hi all, I've developed a win C# app that is actually database driven using SQL server 2000. The idea is that only one application will be installed on a server in a network and the program will be able to run at each client machine by just double-clicking the application executable through a network share. The program supports user logins. What I want to do is find a secure way to control the number of concurrent *users* using the...
6
1376
by: WebMatrix | last post by:
Hello, Here's the situation (I'll try to be brief as possible) I am working on the control which is created dynamically based on XML string. This control consists of a table with number of rows with 3 columns; TextBox, dropdown and a button ("Delete" button) in each column. Also there's one button at the bottom of the table that allows users to add more rows. So more controls will be added programmatically as user adds more rows. What's...
3
1313
by: Rod | last post by:
Today and tomorrow we're demonstrating our ASP.NET application to the external business customers who will be using it (this is what would best be called a B2B application). I've set things up so that the users automatically go against our test server for the database. We'll "go live" next week Monday. For some reason, while demonstrating the app, it was causing lots of errors for users. It became apparent that the issue was one...
20
5649
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just client-side HTML, CSS, etc. What I want to do is somehow insert a *server control* into the , then set the server control's properties at runtime.
1
1479
by: Brian Henry | last post by:
I am trying to make a custom user control that gets a list of users from our database and populates the list, its an owner drawn control also, the problem is, I placed the item onto a form and every time i make a change to the control it reads the database and adds new items to the listing but never gets rid of the old items in the list, the form seems to be makeing a stored copy of the items locally then rebuilding the list ontop of it......
6
1412
by: dana lees | last post by:
Hello, I am developing a c# asp.net application. I have 2 forms. In the first webform ('header') i have a label. I want to reference that label from a different form ('user'), in order to change its' text. How can i do that?
0
1603
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number of text and combo boxes on it (in panels on the tab). These combos were originally simple drop down lists - i.e. you had to select from the list and couldn't enter anything of your own. At that time everything worked fine. Now, the users...
1
2124
by: Smalley | last post by:
Need some help please. Have this code and for some reason it is not working correctly. I am not receiving errors, just the table is not being populated at all. I have created the tbl and the frm and when I open up the db, it is not recording the number of users. I am still new to VBA and would appreciate some assistance. I am running Access 2003 Thanks,
6
1716
by: =?Utf-8?B?UGFycm90?= | last post by:
I cannot access my SQL database in a browser control created in my C# Windows application program I can, however, access the database from an IE browser. I get the ubiquitous "Login failed for NT AUTHORITY\NETWORK SERVICE" error message. I researched all the advice on the internet and tried to add an NT AUTHORITY\NETWORK SERVICE login to my database under the Security/Users tab using SQL Server Mangement. However, there is no NT...
0
8999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9338
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6803
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.