public String IdentificarAcessoDAL(FuncionarioDTO acesso)
{
try
{
conexao.cmd.Connection = conexao.conexao;
string recuperar = "SELECT CARGO.NOME_CARGO FROM LOGIN INNER JOIN FUNCIONARIO ON FUNCIONARIO.CPF_FUNCIONARIO = LOGIN.CPF_FUNCIONARIO INNER JOIN CARGO ON CARGO.ID_CARGO = FUNCIONARIO.ID_CARGO WHERE LOGIN.USUARIO_LOGIN = '" + acesso.User + "' AND LOGIN.SENHA_LOGIN = '" + acesso.Password + "'";
conexao.cmd.CommandText = recuperar;
conexao.conexao.Open();
return funcionarioDTO.Funcao = conexao.cmd.ExecuteScalar().ToString();
}
catch (Exception erro)
{
throw erro;
}
finally
{
conexao.conexao.Close();
}
}
Whenever I type the correct information it runs the application perfectly, but when it does not find in the database, it simply to run the program and displays the following error:
The program searches for the official position, using the login and the password, and this error only appears when the login and / or password is incorrect, otherwise it works perfectly.