views:

37

answers:

1
private Boolean Saveuser(bool isNew)
{
    tb_User user = new tb_User();

    user.User_Name = txtUserName.Text.Trim();
    user.User_LoginName = txtLoginName.Text;
    user.User_Password = txtPassord.Text;
    user.User_ModifiedBy = clsGlobalVariable.strusername;
    user.User_Modified = DateTime.Now;
    user.User_IsDeleted = false;
    user.User_IsUpdated = true;
    user.User_UserGroup = "";
    user.User_UserType = "";
    user.User_WarehouseCode = "";
    user.SetIsNew(isNew);

    user.Save();
}

when I try to insert new user using above coding, it is worik, but try to update existing user by passing isNew (false). It is not working, when I trace inside activerecord.cs, the dirty column count is always 0 for both new and update. How can I update the existing record? Please answer for me? Thanks.

+1  A: 

You should

  1. Get the record
  2. Update record
  3. Save

    User u = User.FetchByID(2345);

    u.User_Name = "blablabla";

    //other User object modifications...

    u.Save();

dario