You can refer this article
public class User
{
public string Username { get; set; }
public string Password { get; set; }
}
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string ValidateUser(User user)
{
int userId = 0;
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("Validate_User"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Username", user.Username);
cmd.Parameters.AddWithValue("@Password", user.Password);
cmd.Connection = con;
con.Open();
userId = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
}
}
string IsValidate = string.Empty;
switch (userId)
{
case -1:
IsValidate = "Username and/or password is incorrect.";
break;
case -2:
IsValidate = "Account has not been activated.";
break;
}
return IsValidate;
}
You can take the Stored Procedure reference from this link.
Simple User Login Form example in ASP.Net