关于Session的赋值与传递问题

.Net技术 码拜 10年前 (2015-03-06) 1295次浏览 0个评论

//记录输入的信息与数据库对比存在就传递Session记录的信息
protected void btnOK_Click(object sender, EventArgs e)
{
SqlData da = new SqlData();
SqlDataReader read = da.ExceRead(“select * from tb_Blog where UserName=””+Session[“Name”].ToString()+”””);
ead.Read();
if (this.txtQues.Text == read[“Question”].ToString() && this.txtAns.Text == read[“Answer”].ToString())
{
Session[“pwd1”] = read[“BlogID”].ToString();
Page.Response.Redirect(“ShowPwd.aspx”);
}
else
{
Response.Write(”

“);
}
ead.Close();
}//codego.net/tags/11/1/
//加载接收信息
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlData da = new SqlData();
SqlDataReader read = da.ExceRead(“select * from tb_Blog where BlogID=”” + Session[“pwd1”].ToString() + “””);
while (read.Read())
{
this.txtPwd.Text = read[“PassWord”].ToString();
}
ead.Close();
}
}
//处理接收的信息
protected void btnChange_Click(object sender, EventArgs e)
{
if (Session[“pwd1”] != null)
{
string com = “update tb_Blog set PassWord=”” + this.txtOKpwd.Text + “” where BlogID=”” + Session[“pwd1”].ToString() + “””;
SqlData da = new SqlData();
ool add = da.ExceSQL(com);
if (add)
{
Response.Write(”

“);
}
else
{
Response.Write(”

“);
}
}
}


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明关于Session的赋值与传递问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!