I'm getting a runtime error
Conversion failed when converting the varchar to int
with this 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();
}