protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Model.MallUser userCurrent = (Model.MallUser)Session["user"]; string UserName = userCurrent.UserName; string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Server.MapPath("/App_Data/bbs.mdb"); OleDbConnection oleConnection = new OleDbConnection(ConnStr); oleConnection.Open(); OleDbCommand mycommand = new OleDbCommand("select CreateTime from OO where UserName='******'", oleConnection); labOrderID.Text = mycommand.ExecuteScalar().ToString(); OleDbCommand mycommand2 = new OleDbCommand("select RealName from OO where UserName='******'", oleConnection); labName.Text = mycommand2.ExecuteScalar().ToString(); OleDbCommand mycommand3 = new OleDbCommand("select Address from OO where UserName='******'", oleConnection); LabAddress.Text = mycommand3.ExecuteScalar().ToString(); OleDbCommand mycommand4 = new OleDbCommand("select UserTel from OO where UserName='******'", oleConnection); labTel.Text = mycommand4.ExecuteScalar().ToString(); oleConnection.Close(); } //Order order = new Order(); //Model.Orders u = (Model.Orders)Session["order"]; //// labOrderID.Text = u.CreateTime; // labName.Text = u.UserName; // LabAddress.Text = u.Address; // labTel.Text = u.UserTel; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { Model.MallUser userCurrent = (Model.MallUser)Session["user"]; UserName.Text = userCurrent.UserName; } catch (Exception ee) { UserName.Text = ee.Message; } string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Server.MapPath("/App_Data/bbs.mdb"); OleDbConnection oleConnection = new OleDbConnection(ConnStr); oleConnection.Open(); OleDbCommand mycommand = new OleDbCommand("select UserTel from MallUser where UserName='******'", oleConnection); UserTel.Text = mycommand.ExecuteScalar().ToString(); OleDbCommand mycommand2 = new OleDbCommand("select UserID from MallUser where UserName='******'", oleConnection); UserID.Text = mycommand2.ExecuteScalar().ToString(); OleDbCommand mycommand3 = new OleDbCommand("select RealName from MallUser where UserName='******'", oleConnection); RealName.Text = mycommand3.ExecuteScalar().ToString(); OleDbCommand mycommand4 = new OleDbCommand("select Address from MallUser where UserName='******'", oleConnection); Address.Text = mycommand4.ExecuteScalar().ToString(); oleConnection.Close(); } }
protected void btnSave_Click(object sender, EventArgs e) { string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Server.MapPath("/App_Data/bbs.mdb"); OleDbConnection oleConnection = new OleDbConnection(ConnStr); Model.MallUser userCurrent = (Model.MallUser)Session["user"]; string UserName = userCurrent.UserName; string Str = "update MallUser set RealName = '" + RealName.Text + "',Address='" + Address.Text + " ' where UserName ='******'"; OleDbCommand myIns = new OleDbCommand(Str, oleConnection); myIns.Connection.Open(); int ni = myIns.ExecuteNonQuery(); myIns.Connection.Close(); if (ni > 0) { Response.Write("<script language=javascript>alert('恭喜您,信息保存成功!');</script>"); } }