We help IT Professionals succeed at work.
Get Started

Caml Query on Item versiion History

2,064 Views
Last Modified: 2013-11-11
I am gettig the following error from the code below:

"The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Too many parameters were provided in this RPC request. The maximum is 2100."

The error occurs as soon as it hits the foreach loop and fails when it gets the item versions information.

I would like to fix this issue using a Caml query or some how using Linq queries.
Can someone show me how to create a caml query or Linq query from the code below.

Or are there any other suggestions besides a hot fix from Microsoft. A hot fix can not be installed on the enviroment this code will be used on.
var sb = new StringBuilder();

foreach (SPListItemVersion itemVersion in  
         item.Web.Lists[item.ParentList.ID]
         .Items[item.UniqueId].Versions)
         {
          SPFieldMultiLineText field =
          itemVersion .Fields[key] 
          as SPFieldMultiLineText;

        if (field != null)
         {
           string comment = field.GetFieldValueAsText
           (itemVersion .Fields[key]);
                                      
            if (comment != null &&
                comment.Trim() != string.Empty)
              {
                sb.Append("\n\r");
                sb.Append(itemVersion .CreatedBy.User.Name)
                .Append("(");
                sb.Append(itemVersion .Created.ToString
               ("MM/dd/yyyy hh:mm tt"));
               sb.Append(")");
               sb.Append(comment);
               row[key)] = sb.ToString();
            }
          }
         }

Open in new window

var sb = new StringBuilder();

foreach (SPListItemVersion itemVersion in  
         item.Web.Lists[item.ParentList.ID]
         .Items[item.UniqueId].Versions)
         {
          SPFieldMultiLineText field =
          itemVersion .Fields[key] 
          as SPFieldMultiLineText;

        if (field != null)
         {
           string comment = field.GetFieldValueAsText
           (itemVersion .Fields[key]);
                                      
            if (comment != null &&
                comment.Trim() != string.Empty)
              {
                sb.Append("\n\r");
                sb.Append(itemVersion .CreatedBy.User.Name)
                .Append("(");
                sb.Append(itemVersion .Created.ToString
               ("MM/dd/yyyy hh:mm tt"));
               sb.Append(")");
               sb.Append(comment);
               row[key)] = sb.ToString();
            }
          }
         }

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE