title: Login page - Checking the database
body: <p>I am trying to make a simple login page, user enters ID and password, and chooses role from a dropdown list:Student, Administrator or Instructor. Here is the code:</p>
  
  <pre><code>protected void loginButton_Click(object sender, EventArgs e)
  {
  
      SqlConnection con = new SqlConnection();
      con.ConnectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=University;Integrated Security=True;Pooling=False";
      //myConn.Open();
      //string strqry = "Insert into students values (" + TextBox1.Text +
      //",'" + TextBox2.Text + "','" + TextBox3.Text + "')";
      //SqlCommand myCom = new SqlCommand(strqry, myConn);
      //int numrow = myCom.ExecuteNonQuery();
      //myConn.Close();
  
      Int32 verify;
      string query1 = "Select count(*) from Login where ID='" + idBox.Text + "' and Password='" + passwordBox.Text + "' and Type='"+ LoginAs.Text +"'" ;
      SqlCommand cmd1 = new SqlCommand(query1, con);
      con.Open();
      verify = Convert.ToInt32(cmd1.ExecuteScalar());
      con.Close();
      if (verify &gt; 0)
      {
          Response.Redirect("succesful.aspx");
      }
      else
      {
          Response.Redirect("unsuccesful.aspx",true);
      }
  
  }
  </code></pre>
  
  <p>The problem is, when i try without checking the value of the dropdown list called "LoginAs", it works fine and makes validation. But when i also check the Type, which is either Student, Administrator or Instructor it always makes unsuccesful login even though all the information is correct. Can anyone help me to find what is wrong?</p>
  
  <p>Thanks</p>