Click here to Skip to main content
16,022,418 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need help on how to go about making sure a user does not log in twice, the validation should be on the C#-code behind interface before registering the user twice in the database. Thanks
Posted
Comments
Sandeep Mewara 22-Jul-10 6:37am    
If you have signin-signout kind of thing in your application, then this does not make much of a sense.

Stopping multiple logins when you have a login feature does not make sense. Please elaborate why you are trying so?

Hi Seundaniel,
There are many ways you can prevent the user from multilogin, irrespective of Windows or Forms authentication on button click event of the login store the UserID
For Web --> Use Cache, Session variables
For Windows / Web you can write user to registry as soon as he logsin , and when again user try to login in the hutton click event registry value will be checked and appropriate message "Already Logged In ...!" can be displayed
 
Share this answer
 
Comments
seundaniel 23-Jul-10 0:31am    
Kindly help with some code please
You could check the database to see if the user is already logged on "somewhere else", and then present them with a dialog box that says something like this:

"You're already logged on. If you login here, any other currently active session to be terminated. Continue?"
 
Share this answer
 
Comments
seundaniel 23-Jul-10 0:29am    
i am new to programming, kindly help out with a form of code please
#realJSOP 23-Jul-10 17:53pm    
I don't have the time or desire to write code for you. Be a programmer, and figure it out.
seundaniel 26-Jul-10 1:24am    
Here on the click of the button...
private void btnClock_Click(object sender, EventArgs e)
{
lblSecure.Text = txbClock.Text;
if (lblSecure.Text != txbClock.Text)
try
{
con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Client Manager\SPORT.mdb");
con.Open();
str1 = "INSERT INTO Log SELECT ID, UName, PhoneNumber FROM Client WHERE ID = '" + txbClock.Text + "'";
comd = new OleDbCommand(str1, con);
Int32 recordsAffected = comd.ExecuteNonQuery();
//String name = rdr.ToString();
txbClock.Clear();
txbClock.Focus();
if (recordsAffected.ToString() == "0")
MessageBox.Show("Not a member yet or Incorrect Clock-In Details.");
else
if (recordsAffected.CompareTo() = lblSecure.Text)
comd.Cancel();

}
catch (Exception ce)
{
MessageBox.Show(ce.Message);
MessageBox.Show(ce.StackTrace);
MessageBox.Show(ce.Source);

}

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