日期:2014-05-18 浏览次数:20627 次
if ((this.usertxt.Text == "") || (this.pwdtxt.Text == ""))
{
Response.Write("<script>alert('用户名、密码不能为空');</script>");
}
else
{
string ConnectionString = "server=localhost;database=user;uid=sa;pwd=123456";
SqlConnection con = new SqlConnection(ConnectionString);
con.Open();
string name = this.usertxt.Text.ToString();
string pass = this.pwdtxt.Text.ToString();
string cmdtxt = "select * from vip where user='" + name + "' and pwd ='" + pass + " '";
SqlCommand cmd = new SqlCommand(cmdtxt, con);
int red = Convert.ToInt32(cmd.ExecuteScalar());
if (red > 0)
{
Session["admin_name"] = this.usertxt.Text.ToString();
Response.Redirect("hello.aspx");
}
else
{
Response.Write("<script>alert('请与管理员联系!');</script>");
}
}