Hey I'm trying to output to a label when I try to add parameters to my mySql query it works fine if I manually set the parameters to "admin" using this sql statement "string sql = "SELECT login_Type FROM schooladmindb.login WHERE Password ='admin'AND Email ='admin'";" but when what to input the variables i get no output
string password = Txtpassword.ToString();
string email = Txtpassword.ToString();
string sql = "SELECT login_Type FROM schooladmindb.login WHERE Password = @password AND Email = @email";
MySqlConnection con = new MySqlConnection("");
con.Open();
MySqlCommand cmd = new MySqlCommand(sql, con);
cmd.Parameters.AddWithValue("@password", password.);
cmd.Parameters.AddWithValue("@email", email);
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string type = reader.GetString(1);
Lbltest.Text = type;
//data2txtz.Text = reader.GetString("id");
//datatxt.Text = reader.GetString("userId");
}
I'm getting no output when I enter admin into both text boxes, I'm not sure where to go from here
string email = Txtpassword.ToString();doesn't sound like it's right to me. And ifTxtpasswordis a textbox, you want theTextproperty, not callingToString...