title: Check if login details are correct for a user in a SQL database using ADO.NET
body: <p>I have a C# MVC4 internet application and would like to check if login details are correct for a user.</p>
  
  <p>I wish to do this from a Forms application using ADO.NET.</p>
  
  <p>Here is the MVC code for a login:</p>
  
  <pre><code>[HttpPost]
  [AllowAnonymous]
  [ValidateAntiForgeryToken]
  public ActionResult Login(LoginModel model, string returnUrl)
  {
      if (ModelState.IsValid &amp;&amp; WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
      {
          return RedirectToLocal(returnUrl);
      }
  
      // If we got this far, something failed, redisplay form
      ModelState.AddModelError("", "The user name or password provided is incorrect.");
      return View(model);
  }
  </code></pre>
  
  <p>Once connected to the SQL database, what SQL code do I need to use as a query to check if a password is correct for a user?</p>
  
  <p>I would like to make a stored procedure if possible, but need to work out the SQL query string code.</p>
  
  <p>How can I check login details for a SQL database user that has been created using the MVC application?</p>
  
  <p>Thanks in advance</p>