C#的问题(关于Session的用法),快来帮帮我啊!!

来源:百度知道 编辑:UC知道 时间:2024/06/04 08:28:25
我在登录成功后加了一句Session["Account"] = txtAccount.Text;
是为了获取当前登录用户的用户名,然后
在绑定的SQL语句中,用到它
where [user].account='" +Session ["Account"].ToString () + "'
这样却根本没有效果,怎么回事??

我想问你:
你登录成功如何实现的?按理要去数据库查找啊!
那下面那条是做什么的呢?
我写的成功调试的:
protected void Button1_Click(object sender, EventArgs e)
{
OleDbConnection conn = dbconn.createConnectionInDefault();
conn.Open();

string username2 = this.username1.Text.Trim();

if (username2 == null || this.pwd1.Text.Trim() == null)
{
Response.Write("<script language='javascript'>alert('用户名、密码、验证码必须填写!');window.history.go(-1);</script>");
Response.End();

}

string password2 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.pwd1.Text.Trim(), "md5");

string yzm1=this.yzm1.Text.Trim();

if (yzm1 != Convert.ToString(Session["yzm2"]))//先检测验证码,再检测用户名和密码
{
this.loginresult.Text = "<font color=blue>验证码错误</