SELECT COUNT(DISTINCT HostName) AS UserCount ;
FROM master.dbo.syslogins logins,master.dbo.sysprocesses procs ;
WHERE logins.SuID=procs.SuID AND procs.Program_Name='MyAppName' ;
AND logins.Name='username'OK, so what the hell does all this do, you ask? Basically it tells me how many computers have logged on to SQL Server using the current user's login name. I expect the answer to be 1, because the user just logged in. I count the distinct host names because if the user has crashed he or she may still have a SQL Server connection that hasn't been cleared. Has long as the user is still using the same computer he or she crashed, you won't get 2 in the UserCount column. The reason I pass the app name in the connection string and then check for it in the SELECT is that I don't want to prevent the user from logging in to SQL Server on multiple machines at once, I just want to keep him or her from logging in to SQL Server using MY application more than once.
I won't go into all system tables involved in the queries. You can probably just check the SQL Server docs or experiment a bit to figure that out.
Hope this helps.
Josh
>I develop apps that use a 5-user, 10-user, etc. concurrent licensing approach. I use a vfp login table with each user 'locking' a record to gain access to a particular module. This works well in VFP, but with client server, I am concerned about WAN performance if users have to use a VFP table on a remote server. Has anyone else come up with concurrent licensing schemes for C/S apps.
>
>Thanks,
>
>KevinJosh Weiss
Tremont Technologies, Inc.