public bool add_taikhoan(DangKi dk) { SqlConnection conn = new SqlConnection(connectString); string sql = @"insert into Login(TaiKhoan,MatKhau) values (@taik,@matK)"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@taik", dk.taiKhoan); cmd.Parameters.AddWithValue("@matk", dk.matKhau); conn.Open(); int count = cmd.ExecuteNonQuery(); conn.Close(); return(count >= 1); }
protected void btndangki_Click(object sender, EventArgs e) { if (DangKidao.check_taikHoan(txttaikhoan.Text)) { Label5.Text = "Tài khoản đã có"; } else { DangKi dK = new DangKi(txttaikhoan.Text, txtmatkhau.Text); if (DangKidao.add_taikhoan(dK)) { Label5.Text = "Đã đăng kí"; } else { Label5.Text = "ERROR "; } } }