日期:2014-05-17 浏览次数:20449 次
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
string zName = ztxname.Text;
string aPassword = upw2.Text;
string aAge = txuserage.Text;
string aSex = rasex.Text;
string aQQ = txuserQQ.Text;
string aAdd = txadd.Text;
string aRole = radrole.Text;
string aMail = txemail.Text;
string conStr = "Data Source=RONEYSAM;Initial Catalog=ASPNETDB09;Persist Security Info=True;User ID=winco;Password=Tobelove920207";
SqlConnection conn = new SqlConnection(conStr);
conn.Open();
string sqlStr=string.Format("insert into tbUser(userName,userPassword,usereAge,userSex,userQQ,userAddress,userRole,userEmail)"
+" values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}');",zName,aPassword,aAge,aSex,aQQ,aAdd,aRole,aMail);
SqlCommand cmd= new SqlCommand(sqlStr,conn);
if (cmd.ExecuteNonQuery() > 0)
{
Session["UName"] = zName;
Response.Write("<script>alert('注册成功!');window.location='Success.aspx'</script>");
}
else
{
Response.Write("<script>alert('注册失败!');</script>");
}
conn.Close();
}
protected void Page_Load(object sender, EventArgs e)
{
if(this.Session["UName"]!=null)
{
this.Label1.Text = this.Session["UName"].ToString();
}
else{
Response.Redirect("Default.aspx");
}
}