关闭

用戶注冊到數據庫

653人阅读 评论(0) 收藏 举报
this.Panel2.Visible=false; con.open(); SqlCommand cmd=new SqlCommand("select * from login where UserName='"+this.UserName.Text.Trim().ToString()+"'",con.con); SqlDataReader sdr=cmd.ExecuteReader(); if(sdr.Read()==true) { this.Label1.Text="用戶名已經存在,請重新填寫"; return; } con.open(); string SqlStr; StringBuilder sb=new StringBuilder(); ArrayList myAL = new ArrayList(); sb.Append("insert into [login] (UserName,UserPwd,PersonUser,PersonDept,PersonWord,PersonSex,PersonTel,PersonEmail,PersonInData,PersonImg) values('{0}','{1}',N'{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')"); s1=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.User_pwd.Text.Trim().ToString(),"md5"); s2=s1.Substring(8,s1.Length-16); myAL.Add(this.UserName.Text.Trim().ToString()); myAL.Add(s2); myAL.Add(this.Txt_UserName.Text.Trim().ToString()); myAL.Add(this.Txt_dept.Text.Trim().ToString()); myAL.Add(this.Txt_Word.Text.Trim().ToString()); if(this.Sex_GG.Checked) myAL.Add(this.Sex_GG.Text); else myAL.Add(this.Sex_MM.Text); myAL.Add(this.Txt_Tel.Text.Trim().ToString()); myAL.Add(this.Txt_Email.Text.Trim().ToString()); myAL.Add(this.Txt_Indata.Text.Trim().ToString()); myAL.Add(this.Image1.ImageUrl.ToString()); SqlStr=string.Format(sb.ToString(),myAL.ToArray()); con.open(); SqlCommand cmd1=new SqlCommand(SqlStr,con.con); cmd1.ExecuteNonQuery(); con.WClose(); con.Alert("注冊成功",Page); Response.Redirect("index.aspx"); Response.Cookies["username"].Value=""+this.UserName.Text+""; Response.Cookies["pwd"].Value=""+s2+""; Response.Cookies["jpower"].Value="42"; Response.Cookies["jhidden"].Value="0";
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:114636次
    • 积分:2008
    • 等级:
    • 排名:第19189名
    • 原创:74篇
    • 转载:37篇
    • 译文:2篇
    • 评论:2条