Insert(注册页面)

private void btnsubmit_Click(object sender, System.EventArgs e)

         {

        

              string username=txtusername.Text;

              string userpassword=txtuserpwd.Text;

              string usersex=rblsex.SelectedItem.Value;

              string birthday=ddlnian.SelectedItem.Text.ToString()+"-"+ddlyue.SelectedItem.Text.ToString()+"-"+ddlri.SelectedItem.Text.ToString();

              string email=txtemail.Text;

              string question=ddlquestion.SelectedItem.Value;

              string answer=txtanswer.Text;

 

                  

              string insert= " INSERT INTO user_info (user_name ,user_pwd,user_sex,user_birthday,user_question,user_answer,user_email) VALUES ('" ;

              insert += username + "', '" ;

              insert += userpassword + "', '" ;

              insert += usersex + "', '" ;

              insert += birthday + "', '" ;

              insert += question + "', '" ;

              insert += answer + "', '" ;

              insert += email + "') " ;

 

              SqlConnection conn = new SqlConnection();

              conn.ConnectionString=ConfigurationSettings.AppSettings["ConnectionString"];

              SqlCommand cmd= new SqlCommand();

              cmd.CommandText=insert;

              cmd.Connection = conn;

 

              conn.Open();

              cmd.ExecuteNonQuery();

             

 

              conn.Close();

              Response.Write("");

         }

 

你可能感兴趣的:(Insert(注册页面))