日期:2014-05-17 浏览次数:20445 次
public bool AdminLogin(string n1, string p1)
{
SqlConnection conn = new SqlConnection(Code.sqlconn);
conn.Open();
string str ="select * from [Admin] where [Name]=@n and [Password]=@p";
SqlCommand comm = new SqlCommand(str,conn);
comm.Parameters.AddWithValue("@n", n1);
comm.Parameters.AddWithValue("@p", p1);
SqlDataReader read = comm.ExecuteReader();
if (read.Read())
{
conn.Close();
return true;
}
else
{
conn.Close();
return false;
}
}
AdminService ads = new AdminService();
if (ads.AdminLogin(user.Value,pwd.Value)==true)
{
Response.Redirect("Default.aspx");
}
else
{
Response.Write("用户或密码错误");
}