I have a problem with this connection to pgsql. I do not know what is happening. I placed a breakpoint in each line of code and it enters all the lines but the user does not recognize me, I do not know if I'm doing it wrong or I'm missing something.
I already put the using npgsql;
and I made a class with the connection string to call only the string and nothing. My conf of pgsql is exact, I already tried everything my knowledge has. I am using a WPF project and I also have the mahapps installed to give me metro and npgsql styles so I can download it from Nuget, I do not know if that helps to determine what is happening.
Here I leave the code fragment.
private void btnaceptar_Click(object sender, RoutedEventArgs e)
{
bool blnfound = false;
NpgsqlConnection conn = new NpgsqlConnection("Server=localhost;Port=5432; User Id=postgres;Password=1234;Database = systemBD");
conn.Open();
NpgsqlCommand cmd = new NpgsqlCommand("Select * from usuario where cod_usu = '" + txt1 + "' and con_usu = '" + txt2 + "' ", conn);
NpgsqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
blnfound = true;
modulos form = new modulos();
form.Show();
this.Hide();
}
if (blnfound == false)
MessageBox.Show("Usuario o Contraseña Incorrecta", "Mensaje de Alerta", MessageBoxButton.OK);
dr.Close();
conn.Close();
}