SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a list programmatically and added columns.but error comes due to column limit.Please help.Here is my code.My logic is:When an item is added to list "Future Projects" a new list shold be created.The new list name should be SP Resources Master + Year obtained from Future Projects.The list is created,but the error comes when adding columns to the new list.I have added the whole weeks of an year as columns.My code is

 public override void ItemAdded(SPItemEventProperties properties)
           if (properties.ListTitle == "Future Projects")
                   SPWeb oSPWeb = properties.Web;
                   oSPWeb.AllowUnsafeUpdates = true;
                   DateTime dtStartDate = onvert.ToDateTime(properties.ListItem["Start Date"]);
                   DateTime dtEndDate=Convert.ToDateTime(properties.ListItem["End Date"]);
                   string startDateYear = string.Format("{0:yyyy}", dtStartDate);
                   string endDateYear = string.Format("{0:yyyy}", dtEndDate);
                   SPWeb oSPWebResources = properties.Web;
                   oSPWebResources.AllowUnsafeUpdates = true;
                   SPListCollection oSPListCollection = oSPWebResources.Lists;
                   //Add Title,Description and ListTemplate
                   string ListName = "SP Resources Master " + startDateYear;                  
                   foreach (SPList oSPList in oSPListCollection)
                          if (oSPList.Title == ListName)
                               goto finish;
                   if ((Convert.ToString(startDateYear) == "2012") || (Convert.ToString(endDateYear) == "2012"))
                           goto finish;
                       oSPListCollection.Add(ListName, "SP Resources Master", SPListTemplateType.GenericList);
                       SPList oSPListResources = oSPWeb.Lists[ListName];
                       SPView oSPViewResources = oSPListResources.DefaultView;
                       //Set Start Date and End Date                  
                       string strStartingDate = "1/1/" + startDateYear;
                       DateTime dtStartingDate = Convert.ToDateTime(strStartingDate);
                       string strEndingDate = "12/31/" + endDateYear;
                       DateTime dtEndingDate = Convert.ToDateTime(strEndingDate);
                       /* add the new fields to the list */
                       List<string> oList = GetWeeksBetweenDateRange(dtStartingDate, dtEndingDate);
                       foreach (string str in oList)
                           SPFieldDateTime fldDateTime = (SPFieldDateTime)oSPListResources.Fields.CreateNewField(SPFieldType.DateTime.ToString(), str);
                           fldDateTime.DisplayFormat = SPDateTimeFieldFormatType.DateTime;

                       oSPWeb.AllowUnsafeUpdates = false;
               finish: ;
       public List<string> GetWeeksBetweenDateRange(DateTime startDate, DateTime endDate)
           weeks = new List<String>();
           while (startDate <= endDate)
               int currentDayOfTheWeekInNo = (int)startDate.DayOfWeek;
               DateTime weekStartDate = startDate.AddDays(-currentDayOfTheWeekInNo);
               DateTime weekEndDate = weekStartDate.AddDays(6);
               string weekRange = weekStartDate.ToString("MMM dd yyyy") + " - " + weekEndDate.ToString("MMM dd yyyy");
               startDate = weekStartDate.AddDays(7);
           return weeks;
share|improve this question

You should not increase the column limits defined in SharePoint Server 2010 capacity management: Software boundaries and limits, but instead you should rethink your design. Instead of putting all weeks into a single item in the new list you probably need to create an item for each week.

When you reach the column limit you have in fact already passed the limit for good performance long ago. Performance will start to degrade when the ListItem has to be split into multiple SQL rows and the limit will be reached when the ListItem has to be split into more than 6 SQL rows.

But that said, if you in spite of my recommendation wants to increase the limit then you can increase the SPWebApplication.MaxListItemRowStorage property

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.