未将对象引用设置到对象的实例 求大神帮忙看看

图片说明
DAL层的方法 public static int UpdateStaff(Staff st)
{
string sql = string.Format("update Staff set StaffId={0},Name='{1]',Address='{2}',Phone={3},Email='{4}',Age={5},BranchId={6}", st.StaffId, st.Name, st.Address, st.Phone, st.Email, st.Age, st.Branch.Id);
return DBHelper.ExecuteCommand(sql);
}
这个是数据库

st.Branch为空了吧

你有DEBUG过你的代码么

Staff st,这个st变量为null引用。。

st没有值,或者st.Branch为null,或者它们的某个属性为null,调试下。