日期:2014-05-17 浏览次数:20508 次
aspx.cs:
protected void btnSave_Click(object sender, EventArgs e)
{
User user = new User();
user.ID = moduleID.Text;
user.UserName = moduleName.Text;
user.UserRole = new UserRole { RoleID = ddlRole.SelectedValue };//UserRole为导航属性
UserBLL.add(user);
}
BLL.cs:
public static void add(User user)
{
UserDAL.add(user);
}
DAL.cs:
public static void add(User user)
{
CRMEntities db = new CRMEntities();
db.AddToUsers(user);
db.SaveChanges(); //此处报错:更新项时出错;
db.Dispose();
}