title: Conversion failed when converting the varchar to int mvc C#
body: <p>I'm getting a runtime error </p>
  
  <blockquote>
    <p>Conversion failed when converting the varchar to int </p>
  </blockquote>
  
  <p>with this code:</p>
  
  <pre><code>public ActionResult Index(Model1 m)
  {
      string q = "select username, password from login where username=@username and password=@password ";
  
      con.Open();
  
      SqlCommand cmd = new SqlCommand(q, con);
      cmd.Parameters.AddWithValue("@username", m.username).ToString();
      cmd.Parameters.AddWithValue("@password", m.password).ToString();
  
      SqlDataReader dr = cmd.ExecuteReader();
  
      if (dr.Read())   // getting error at this point
      {
          return RedirectToAction("upload");
      }
      else
      {
          ViewData["Message"] = "invalid username or password";
      }
  
      con.Close();
  
      return View();
  }
  </code></pre>