62,046
社区成员
发帖
与我相关
我的任务
分享
protected void ButtonLogin_Click(object sender, EventArgs e)
{
string connstr = ConfigurationManager.ConnectionStrings["baodateConnectionString"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connstr))
{
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "select count(*) from customer where cusTel=@Id and cusPw=@pass";
cmd.Parameters.AddWithValue("@Id", TextBoxId.Text);
cmd.Parameters.AddWithValue("@pass", TextBoxPwd.Text);
conn.Open();
int count = (int)cmd.ExecuteScalar();
if (count > 0)
{
Response.Redirect("index.aspx", true);
}
else
{
Response.Write("<script>alert('用户名或密码错误!')</script>");
}
}
}
Session["username"] = "username";
Session["password"] = "password";