I created a Login application, I made the connection to the database, I get the user and password registered in my bank. But what I want is, if the user tries more than three times to get in and has something wrong, block the textbox and button .
You would have to make the comparison with the user registered with the bank.
Follow the code as far as I've done.
{
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, erases his password or his user, the textbox would be disabled. More or less like this: txtUserName.Text.Enabled = false