title: Overwrite Major Version Using Object Model
body: <p>I have versioning and checkin/checkout enabled in a SharePoint 2010 list, and for business-related reasons, would like to update information in a field: overwriting the field data for all versions in a similar manner and in place so that the version numbers do not change. </p>
  
  <p>If I call SPListItemVersion.ListItem.UpdateOverwriteVersion(), it fails stating that I need to check out the item before making changes to it. Makes sense. So I precede the update statement with SPListItemVersion.ListItem.CheckOut() statement, attempt the update, and receive an error that I cannot overwrite a published version. I've also attempted to precede the check out with SPSite.AllowUnsafeUpdates = true, setting it back to false after the update call, but the latter error still occurs. Any ideas?</p>
  
  <p>Stripped code below:</p>
  
  <pre><code>foreach (SPListItemVersion itemVersion in item.Versions){
    itemVersion.ListItem.File.CheckOut(SPFile.SPCheckOutType.Online, itemVersion.ListItem.File.TimeLastModified.ToString());
    site.AllowUnsafeUpdates = true;
    itemVersion.ListItem["FieldName"] = "changed value here";
    itemVersion.ListItem.UpdateOverwriteVersion();
    site.AllowUnsafeUpdates = false;
    itemVersion.ListItem.File.CheckIn("Updated list item version", SPCheckinType.OverwriteCheckIn);
  }
  </code></pre>