[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public bool login(string uname, string pwd)
{
//SqlConnection con = new SqlConnection();
//SqlCommand cmd = new SqlCommand();
//con.ConnectionString = ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
//SqlDataAdapter da = new SqlDataAdapter("select * from UserList where UserName ='" + uname + "' and password='" + pwd + "' ", con);
//DataSet ds = new DataSet();
//da.Fill(ds);
//return ds;
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand();
con.ConnectionString = ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
if (con.State == ConnectionState.Closed)
{
con.Open();
}
cmd.CommandText = "select * from UserList where UserName=@username and Password=@pwd";
cmd.Connection = con;
cmd.Parameters.Add("@username", SqlDbType.VarChar, 50).Value = uname;
cmd.Parameters.Add("@pwd", SqlDbType.VarChar, 50).Value = pwd;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read() == true)
{
return true;
}
else
{
return false;
}
con.Close();
}