登录按钮
protected void Button1_Click(object sender, EventArgs e)
{
OleDbConnection conn1 = getconnection();
string sql = "select * from information where iphone='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'";//查询数据库
OleDbCommand cmd = new OleDbCommand(sql, conn1);
conn1.Open();//打开数据库
OleDbDataReader dr;
dr = cmd.ExecuteReader();
int i = 0;
while (dr.Read())
{
System.Web.HttpContext.Current.Session["iphone"] = dr.GetString(2);
System.Web.HttpContext.Current.Session["password"] = dr.GetString(2);
i++;
}
if (i == 0)
MessageBox.Show("用户名或密码错误!请检查重新输入");
else
Response.Redirect("index.aspx");
dr.Dispose();
cmd.Dispose();
conn1.Close();//关闭数据库
}
重置按钮
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text="";
TextBox2.Text = "";
}