7
I created a Login application, made the connection to the database, I can get the user and password registered in my database. But what I want, is, if the user tries more than three times to enter and there is something wrong, block the textbox and button.
You would have to make the comparison with the registered user in the bank.
Follow the code to where I made it.
{
bool blnFound = false;
NpgsqlConnection conn = new NpgsqlConnection("Server=localhost;Port=5432;User Id=postgres;Password=****;Database=HHH");
conn.Open(); //abrir conexão
NpgsqlCommand cmd = new NpgsqlCommand("select * from login where nome = '" + txtUserName.Text + "' and senha = '" + txtSenha.Text + "'",conn);
NpgsqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
blnFound = true;
Principal pc = new Principal();
pc.Show();
this.Hide();
}
if(blnFound==false)
MessageBox.Show("Nome ou senha estão incorrentos!","Erro",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
dr.Close();
conn.Close();
}
When the user misses their password or their user, the textbox would be disabled. Sort of like this: txtUserName.Text.Enabled = false
Of course, all you have to do is edit the question, post everything you’ve ever done and tell us where you’re tangled up. Maybe there’s a way even better than what you’re doing but we need more details.
– Maniero