C(#) asp.net修改密码
请教高手指教 怎么修改密码:我用的是Linq 连接数据库,下面是我在修改按钮上写的代码,请教 是在哪里出错 修改不了?
protected void Button1_Click(object sender, EventArgs e)
{
if (Session["username"]!=null)
{
myUserDataContext context = new myUserDataContext();
var p = "";
var q = from o in context.UserInfoTable
select new {
p=o.UserPwd
};
if (TextBox1.Text!=p)
{
RequiredFieldValidator1.ErrorMessage = "原始密码不正确!";
//Response.Write("<script>alert('原始密码不正确')</script>");
}
else
{
myUserDataContext db = new myUserDataContext();
UserInfoTable ui = new UserInfoTable();
ui.UserPwd = TextBox2.Text;
db.UserInfoTable.InsertOnSubmit(ui);
db.SubmitChanges();
Response.Write("<script>alert('恭喜你修改密码成功')</script>");
Response.Redirect("Default.aspx");
}
}
else
{
Response.Redirect("UserLogin.aspx");
}
}
答案:LINQ用一句话写 var q = from o in context.UserInfoTable where o.UserPwd=TextBox1.Text
上一个:asp取字符串
下一个:asp如何猎取javascript里的变量