web开发练习题
String Sex = gender.Text;
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=LHAN-PC\\SQLEXPRESS;Initial Catalog=test;Integrated Security=True"; conn.Open();
if (username.Text != "") {
String sqlstr =
"select count(*) from users where [username]='" + username.Text + "'"; SqlCommand comm1 = new SqlCommand(sqlstr, conn); int num = Convert.ToInt32(comm1.ExecuteScalar()); if (num > 0) {
Validator1.Text = "用户已存在"; } else {
sqlstr =
"insert into users(username,name,gender,birthday,email) " + "values('" + User + "','" + Name + "','" + Sex + "','" + "')"; SqlCommand comm = new SqlCommand(sqlstr, conn); comm.ExecuteNonQuery(); conn.Close();
Response.write("注册成功"); } } }
//重置
protected void Reset_Click(object sender, EventArgs e) {
username.Text = ""; password.Text = ""; password1.Text = ""; uname.Text = ""; gender.Text = ""; birth.Text = ""; email.Text = "";