1
I have the following code in my application:
public Usuario checkLogin(Usuario entity)
{
//return
Usuario userEntity = new Usuario();
connection = mysql.OpenConnection();
try
{
MySqlCommand stm = new MySqlCommand();
MySqlDataReader data;
stm.CommandText = "CALL validaLogin(?login, ?senha)";
stm.Connection = connection;
stm.Parameters.AddWithValue("?login", entity.Login);
stm.Parameters.AddWithValue("?senha", entity.Senha);
var id = stm.ExecuteScalar();
errorUtil.showCustomAlert(id.ToString());
} catch(MySqlException ex)
{
errorUtil.showDBError(ex);
} finally{
connection.Close();
}
return userEntity;
}
Its function is to basically receive a user and password and perform login validation through stored Procedure validaLogin
. However, when passing the attribute Login
of the object entity
my query simply not returned anything (necessarily need to return because the data I type in the form are identical to those saved in Mysql).
However, if I replace the object attribute with a string
(as below) I get success in my query.
stm.Parameters.AddWithValue("?login", "logindousuario");
stm.Parameters.AddWithValue("?senha", "senhadousuario");