I have some issue's, ive seen a peace of code on the internet only this whas done with Oledb.
Now i have rewrited the code for MySQL.data.mysqlclient as followed:
MySqlDataReader dr = null;
MySqlCommand cmd = null;
string cmdstr = "SELECT * FROM users WHERE email='"+UsrName.Text+"' and password='"+PassWrd.Text+"' LIMIT 1";
dr = cmd.ExecuteNonReader();
cmd = new MySqlCommand(cmdstr, connection);
cmd.Dispose();
if (dr.Read() == true)
{
MessageBox.Show("Succesvol ingelogd");
}
else
{
MessageBox.Show("Geen juiste gegevens");
}
connection.Close();
}
Now the problem is another method for dr = cmd.ExecuteNonReader().
UPDATE----------------
string server;
string database;
string uid;
string password;
server = "localhost";
database = "cmstt";
uid = "root";
password = "";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection = new MySqlConnection(connectionString);
connection.Open();
MySqlDataReader dr = null;
MySqlCommand cmd = null;
string cmdstr = "SELECT * FROM users WHERE email='"+UsrName.Text+"' and pass='"+PassWrd.Text+"' LIMIT 1";
dr = cmd.ExecuteReader();
cmd = new MySqlCommand(cmdstr, connection);
if (dr.Read() == true)
{
MessageBox.Show("Succesvol ingelogd");
}
else
{
MessageBox.Show("Geen juiste gegevens");
}
cmd.Dispose();
connection.Close();
cmd.Parameters.Add("@email", email);