Click here to Skip to main content
15,907,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am looking for a way to determine who is connected to my windows application. First I looked at who was connected to the sql server but I read that will only show active users. So I guess I need a way to store the username when they log in into a table but remove it when they log off.

I will eventually want to put this information into a listbox or datagridview

I know ENVIRONMENT.USERNAME but not sure how to do this.
Posted

1 solution

AFAIK Environment.UserName only gives the User of the Operating System on the particular machine it runs on.

(Don't know what happened there, got cut off mid-stream)

So your program could call Environment.UserName or My.User.Name and send that information to the database where it could store the Machine Name, User Name and Time.

(This is really odd 2nd time)
Then in the OnFormClosing event handler call it again and send that to the server where the logout time can be stored.

There is probably a better solution than this but this should work.
 
Share this answer
 
v3
Comments
wiswalld 3-Feb-11 17:22pm    
I thought about that and when they log off it would store the log off time. But I read that could really bloat my database. I would somehow need to delete that record when they log out.
Henry Minute 3-Feb-11 17:27pm    
I don't know how many users you have but you could have a procedure that runs every day and deletes any user record over, say, 48 hrs old.
wiswalld 3-Feb-11 17:37pm    
That looks like the way I will go

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900