Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool Repair(Category cat)
- {
- string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\ThuVien.accdb;";
- OleDbConnection connection = new OleDbConnection(connectionString);
- connection.Open();
- // 2. Chuẩn bị câu truy vấn
- string sql = "update Category set TenSP= @TenSP, DungTich = @DungTich, DoCon = @DoCon, XuatXu = @XuatXu, Gia = @Gia where MaSP = @MaSP";
- OleDbCommand command = new OleDbCommand(sql, connection);
- command.Parameters.Add("@TenSP", OleDbType.VarChar).Value = cat.TenSP;
- command.Parameters.Add("@DungTich", OleDbType.Integer).Value = cat.DungTich;
- command.Parameters.Add("@DoCon", OleDbType.Single).Value = cat.DoCon;
- command.Parameters.Add("@XuatXu", OleDbType.VarChar).Value = cat.XuatXu;
- command.Parameters.Add("@Gia", OleDbType.Integer).Value = cat.Gia;
- command.Parameters.Add("@MaSP", OleDbType.VarChar).Value = cat.MaSP;
- bool ret = false;
- try
- {
- ret = command.ExecuteNonQuery() == 1;
- }
- catch (Exception ex)
- {
- connection.Close();
- return ex.Equals(false);
- }
- connection.Close();
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement