问题描述
登陆的代码如下:protectedvoidButton2_Click(objectsender,EventArgse){StringUid=TextBox1.Text.ToString();StringUPwd=TextBox2.Text.ToString();StringUCode="";SqlDataReaderDr;basesqlSqlObj=newbasesql();StringSqlStr;SqlStr="select*fromU_infowhereu_name='"+Uid+"'andu_pwd='"+UPwd+"'";Dr=SqlObj.ExecuteReader(SqlStr);if(Dr.Read()){UCode=Dr["u_id"].ToString();Dr.Close();SqlStr="updateu_infosetlogintimes=logintimes+1,lastlogin='"+System.DateTime.Now+"'whereu_id='"+UCode+"'";SqlObj.ExecuteNonQuery(SqlStr);System.Web.Security.FormsAuthentication.SetAuthCookie(UCode,false);Session["u_id"]=Dr["U_id"];if(Request.QueryString["url"]!=null){StringUrl;Url=Request.QueryString["url"].ToString()+".aspx";Response.Redirect(Url);}else{Response.Redirect("shouye.aspx");}}else{Label1.Text="错误的用户名或密码!";}}修改资料的代码:publicpartialclassxgzl:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(HttpContext.Current.User.Identity.IsAuthenticated==false){Response.Redirect("zc.aspx?url=xgzl");}SqlDataSource1.SelectParameters["u_id"].DefaultValue=HttpContext.Current.User.Identity.Name.ToString();}运行时报错vachar不能转化为int;protectedvoidFormView1_ItemUpdating(objectsender,FormViewUpdateEventArgse){FileUploadFileObj;StringthePath=Server.MapPath("userpic");FileObj=(FileUpload)FormView1.FindControl("face");if(FileObj.HasFile){if(!Directory.Exists(thePath)){Directory.CreateDirectory(thePath);}FileObj.SaveAs(thePath+"\"+FileObj.FileName);e.NewValues["face"]=FileObj.FileName;}}
解决方案
解决方案二:
表中你设了自动增量种子?
解决方案三:
Convert.ToInt32(HttpContext.Current.User.Identity.Name.ToString());