Hello, I'm a beginner in programming and I'm having trouble connecting MySQL in C #, where the code does not check and goes into the catch action. Here is the code:
conexaoDataSet = new DataSet();
conexao = new MySqlConnection("SERVER=127.0.0.1; DATABASE=tcc; UID=root; PASSWORD=;");
try
{
conexao.Open();
MySqlCommand verifica = new MySqlCommand("SELECT * FROM CMS_pilots WHERE nome='" + txt_login.Text + "' and senha ='" + txt_senha.Text + "'", conexao);
bool resultado = verifica.ExecuteReader().HasRows;
if (resultado == true)
{
conexao.Close();
adm f2 = new adm();
f2.Show(this);
Hide();
}
else
{
MessageBox.Show("Login inválido!");
conexao.Close();
}
}
//erro acontece a partir de aqui
catch
{
MessageBox.Show("Erro de conexão com o banco de dados");
conexao.Close();
}
}
}
}