private void btnUpdate_Click(object sender, EventArgs e)
{
using (testEntities Setupctx = new testEntities())
{
var toBeUpdatedStart = txtStart.Text;
var toBeUpdatedStop = txtStop.Text;
shifthour updateShiftStart;
shifthour updateShiftStop;
updateShiftStart = Setupctx.shifthours.FirstOrDefault(u => u.shiftTiming_start == toBeUpdatedStart);
updateShiftStop = Setupctx.shifthours.FirstOrDefault(p => p.shiftTiming_stop == toBeUpdatedStop);
updateShiftStart.shiftTiming_start = txtStart.Text; <-- error prompt here
updateShiftStop.shiftTiming_stop = txtStop.Text;
Setupctx.SaveChanges();
txtStart.Text = "";
txtStop.Text = "";
MessageBox.Show("Shift Timing Has Been Updated.");
}
}
嗨,有人知道这段代码有什么问题吗?更多信息:这是为员工编辑轮班时间。当我输入新的开始和停止时间时,错误提示出来并说“对象引用未设置为对象的实例”。