Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnLuu_Click(object sender, EventArgs e)
- {
- DataRow row = dt.NewRow();
- row["Tên"] = btnHoten.Text;
- row["GiớiTính"] = btnGioi.Text;
- row["NgàySinh"] = btnNgaysinh.Text;
- row["TìnhTrạng"] = btnTinhtrang.Text;
- row["NơiSinh"] = btnNoisinh.Text;
- row["NghềNghiệp"] = btnNghenghiep.Text;
- row["ĐịaChỉHiệnTại"] = btnDiachi.Text;
- row["SốĐT"] = btnSodt.Text;
- row["Cha"] = btnCha.Text;
- row["Mẹ"] = btnMe.Text;
- row["ConTrai"] = btnContrai.Text;
- row["ConGái"] = btnCongai.Text;
- dt.Rows.Add(row);
- SqlCommand cmdInsert = new SqlCommand();
- cmdInsert.Connection = con;
- cmdInsert.CommandType = CommandType.Text;
- cmdInsert.CommandText = @"INSERT INTO DanhSach ( Tên, GiớiTính, NgàySinh, TìnhTrạng, NơiSinh, NghềNghiệp, ĐịaChỉHiệnTại, SốĐT, Cha, Mẹ, ConTrai, ConGái)
- VALUES ( @Tên, @GiớiTính, @NgàySinh, @TìnhTrạng, @NơiSinh, @NghềNghiệp, @ĐịaChỉHiệnTại, @SốĐT, @Cha, @Mẹ, @ConTrai, @ConGái) ";
- cmdInsert.Parameters.Add("@Tên", SqlDbType.NVarChar, 50, "Tên");
- cmdInsert.Parameters.Add("@GiớiTính", SqlDbType.NVarChar, 50, "GiớiTính");
- cmdInsert.Parameters.Add("@NgàySinh", SqlDbType.NVarChar, 50, "NgàySinh");
- cmdInsert.Parameters.Add("@TìnhTrạng", SqlDbType.NVarChar, 50, "TìnhTrạng");
- cmdInsert.Parameters.Add("@NơiSinh", SqlDbType.NVarChar, 50, "NơiSinh");
- cmdInsert.Parameters.Add("@NghềNghiệp", SqlDbType.NVarChar, 50, "NghềNghiệp");
- cmdInsert.Parameters.Add("@ĐịaChỉHiệnTại", SqlDbType.NVarChar, 50, "ĐịaChỉHiệnTại");
- cmdInsert.Parameters.Add("@SốĐT", SqlDbType.NVarChar, 50, "SốĐT");
- cmdInsert.Parameters.Add("@Cha", SqlDbType.NVarChar, 50, "Cha");
- cmdInsert.Parameters.Add("@Mẹ", SqlDbType.NVarChar, 50, "Mẹ");
- cmdInsert.Parameters.Add("@ConTrai", SqlDbType.NVarChar, 50, "ConTrai");
- cmdInsert.Parameters.Add("@ConGái", SqlDbType.NVarChar, 50, "ConGái");
- da.InsertCommand = cmdInsert;
- da.Update(dt);
- MessageBox.Show("Bạn đã thêm thành công!", "THÔNG BÁO", MessageBoxButtons.OK);
- Close();
- disconnect();
- Dispose();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement