More in this section

Forums / Developing with Sitefinity / You cannot change a value of an object that is not in transaction

You cannot change a value of an object that is not in transaction

2 posts, 0 answered
  1. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    08 Feb 2010
    Link to this post
    I could use some help here guys, i have not found any information on why i am recieving this error and my code looks fine according to many of the examples i have found.

    Here it is:

    Guid guid = new Guid(cboSubscriberLists.SelectedValue);
     
    DataManager dManager = new DataManager();
    IList allsubs = dManager.GetSubscribersOfGroup(guid, string.Empty);
     
    try
    {
        foreach (IGroupSubscriber sub in allsubs)
        {
            ISubscriber currsub = sub.Subscriber;
     
     
            if (CheckEmail(currsub.Email))
            {
                if (chkResetNames.Checked)
                {
    //Exception here:
                    currsub.FirstName = char.ToUpper(currsub.FirstName[0]) + currsub.FirstName.Substring(1);
                    currsub.LastName = char.ToUpper(currsub.LastName[0]) + currsub.LastName.Substring(1);
     
                    dManager.SaveSubscriber(currsub);
                }
            }
            else
            {
                //dManager.DeleteSubscriber(currsub.SubscriberId);
            }
        }
    }
    catch (Exception ex)
    {
        errorString = "Error processing request.";
    }

    All i want to do is update the first and last name of every subscriber in the group.

    Duncan
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    08 Feb 2010
    Link to this post
    Hi Duncan Evans,

    You need to get the subscriber through the manager before making any changes to it. This is what the nolnet error says.

    Below is a sample code

    DataManager dManager = new DataManager();
            Guid guid = new Guid("7721E459-9650-4CB0-BFD4-E198E30EB81A");
            IList allsubs = dManager.GetSubscribersOfGroup(guid, string.Empty);
            foreach (IGroupSubscriber sub in allsubs)
            {
                ISubscriber currsub = dManager.GetSubscriber(sub.SubscriberId);
                currsub.FirstName = char.ToUpper(currsub.FirstName[0]) + currsub.FirstName.Substring(1);
                currsub.LastName = char.ToUpper(currsub.LastName[0]) + currsub.LastName.Substring(1);
                dManager.SaveSubscriber(currsub);
            }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
2 posts, 0 answered