Retrieve Logged In users..

aldrin_roxas

New member
Joined
Nov 7, 2010
Messages
3
Location
Philippines
Programming Experience
Beginner
How can I retrieve and show in a Listbox the users logged in? Im using a database to store the accounts.. Im quite new in VB lang.. Need help please.. Thanks! :D
 
Welcome to the forums :)

I've done something fairly similar to what you seem to be asking, what I did was set up a session table in the database and then add an entry into that table saying that the user that just logged in, logged in at this time. Then periodically have the table cleared of any entries that are too old (you'll have to identify what you consider to be too old). When the user logs out of the system then you would remove their entry from the table. I personally did the session stuff with a class.

By doing that you have a reasonably accurate list of who is logged in, obviously if the application crashes then their entry may stay in there, but thats why you delete the ones that are too old.

I hope that helps

Satal :D
 
Ok.. So I need to create another table that updates when users logged in? Im really quite new here, I've skipped most of the basics because I need to create a system immediately.. What should I do in the class? How can i create the session stuff? Enlighten me please! :D
Thanks for your reply!
 
You could make another table with the fields "UserName", "Login Time". Now, what your system needs to do is, when you load the combo-box that loads up al the names of the logged in users, you look at this table. And, when someone logs out, or terminates the program, you need to use an sql statement like "Delete * From LoginTbl WHERE Username = "Username". That way it's a comprehensive list of people logged in at the time. I hope this gets you a little closer :p
 
Back
Top