good, I have the query, I am with a small project in C #, but I have the problem that a query that when executing it in mysql brings me the results correctly but when it is executed in my code, it recognizes me that it returns a row, but when I run the .read () it does not return anything, and if I check what it returns, it shows me the following message
enumeration yielded no results
It is clear that the parameters are passed correctly, but that simply fails, and when I review the non-public parameters, I find the resultset with the values I was looking for
ColumnsDB and queryes is a resource file to replace the names of the columns
query used:
Select * FROM usuarios WHERE username = '{0}' AND password = '{1}'
the code in question is this:
string conex = Conn.Connexion();
MySqlConnection con = new MySqlConnection(conex);
try
{
MySqlCommand comando = new MySqlCommand();
comando.CommandText = string.Format(queryes.Login, txtUsuario.Text, txtPasswrd.Text);
comando.CommandType = CommandType.Text;
comando.Connection = con;
con.Open();
var reader = comando.ExecuteReader();
var list = new List<UsuarioEntity>();
if (reader.HasRows)
{
while (reader.Read())
{
list.Add(new UsuarioEntity
{
User = (string)reader[ColumnasDB.username],
Nombre = (string)reader[ColumnasDB.nombre],
Apellido = (string)reader[ColumnasDB.apellido],
Matricula = (int)reader[ColumnasDB.matricula],
Perfil = (string)reader[ColumnasDB.perfil],
Activo = (bool)reader[ColumnasDB.isactive],
});
}
}
if (reader.ToString() != string.Empty)
{
UsuarioEntity user = new UsuarioEntity();
user.Nombre = txtUsuario.Text;
user.Perfil = reader.ToString();
MessageBox.Show("ConexionAbiertaCorrectamente");
}
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
version of .Net 4.6