0

I need help on how to INSERT, UPDATE and DELETE data using entity-framework. But it is not working. Give me an example?

my code Edit:

var maso = Request.Cookies["NguoiDung"].Value;
using (CalibraMainEntities dv = new CalibraMainEntities())
{
    Device dev = new Device();
    dev.KMH = txtKMH.Text;
    dev.Name_TB = txtNameTB.Text;
    dev.Model = txtModel.Text;
    dev.Serial = txtSerial.Text;
    dev.Date_Entry = DateTime.Parse(txtNgayVe.Text);
    dev.Main_Place = txtMainPlace.Text;
    dev.Calibra_Place = txtCalibraPlace.Text;
    dev.Location = txtLocation.Text;
    dev.Staff_ID = maso;
    dev.Workshop = int.Parse(drWorkshop.SelectedValue);
    dev.Status = int.Parse(drStatus.SelectedValue);
    dev.Ware_ID = int.Parse(drWareHouse.SelectedValue);
    dv.Devices.Attach(dev);
    dv.Entry(dev).State = EntityState.Modified;
    dv.SaveChanges();
}
dtlvd
  • 457
  • 1
  • 8
  • 21
Mr Trung
  • 33
  • 1
  • 7

0 Answers0