public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; string str = context.Request["use"]; string str1 = context.Request["password"]; DataTable ds = Sqlhelper1.ExecuteDataTable("select * from student where id=@id and keys=@keys", new SqlParameter("@id", str), new SqlParameter("@keys", str1)); if (ds.Rows.Count == 1) { context.Response.Write("ok"); foreach (DataRow row in ds.Rows) { int id = (int)row["id"]; string keys = (string)row["keys"]; string name = (string)row["name"]; string xingbie = row["xingbie"].ToString(); int age = (int)row["age"]; context.Response.SetCookie(new HttpCookie("id", id.ToString())); //context.Response.SetCookie(new HttpCookie("name", name.ToString())); //context.Response.SetCookie(new HttpCookie("xingbie", xingbie.ToString())); //context.Response.SetCookie(new HttpCookie("age", age.ToString())); //context.Response.Redirect("my_info.aspx"); //context.Response.Write("姓名:" + name + "性别:" + xingbie + "年龄:" + age + "\n账号:" + id + "\n密码:" + keys); } } else { context.Response.Write("error"); } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie cookie1 = Request.Cookies["id"]; //HttpCookie cookie2 = Request.Cookies["name"]; //HttpCookie cookie3 = Request.Cookies["xingbie"]; //HttpCookie cookie4 = Request.Cookies["age"]; id = cookie1.Value; dt = Sqlhelper1.ExecuteDataTable("select * from student where id=@id", new SqlParameter("@id", id)); da = Sqlhelper1.ExecuteDataTable("select * from student ", new SqlParameter("@id", id)); // (DataRow row in ds.Rows) for (int i = 0; i < dt.Rows.Count; i++) { name = dt.Rows[i]["name"].ToString(); xingbie = dt.Rows[i]["xingbie"].ToString(); age = dt.Rows[i]["age"].ToString(); } // id = cookie1.Value; //name = cookie2.Value; //xingbie = cookie3.Value; // age = cookie4.Value; }
protected void Page_Load(object sender, EventArgs e) { id = Convert.ToInt32(Request["id"]); dt = Sqlhelper1.ExecuteDataTable("select * from student where id=@id", new SqlParameter("@id", id)); }