samedi 24 décembre 2016

If condition doesn't work

if (reader.Read() != false)
{
    string type = reader.GetValue(0).ToString();
    if (type == "Admin")
    {
        MessageBox.Show("type");
        admin pnl = new admin();
        pnl.Show();
        textBox1.Text = "";
        textBox2.Text = "";
    }
    else if (type == "User")
    {
        MessageBox.Show(type, "user");
        user pnl = new user();
        pnl.Show();
        textBox1.Text = "";
        textBox2.Text = "";
    }
    else
    {
        MessageBox.Show("Incorrect Data Type!");
        MessageBox.Show(type);
    }
}

I get the user type from the data base, and check if its admin type or user type. but the if condition doesn't work, it goes straight to the else statement every time.

Aucun commentaire:

Enregistrer un commentaire