Incoming Tabular Data Stream Incorrect

This morning my team fielded an error we had not seen before in a production site.  When performing a lookup, the following exception bubbled up:

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.

Upon investigation, we found that a Linq query using the .Contains() clause was the culprit.

It appears that Entity Framework was translating the .Contains() clause to a WHERE x IN () when setting up the SQL SELECT statement to run.  In our case, we had done a retrieval of records first, then passed that list into the Contains.  It worked fine until the list exceeded 2100 entries.

We were able to just refactor our lookup to eliminate the .Contains() clause.

Part of what made this an unusual case was that even in production, this system had run for 2 years without any issues.  But as the number of records grew through the system’s use, it was only a matter of time before we exceeded that boundary imposed by SQL Server.

About the author

derek Derek Smith is a software developer with 20 years of history developing on the Microsoft platform. He is the founder of HomeSpot HQ, and is the Director for Microsoft SharePoint Professional Services at rmsource, inc. in Raleigh, NC. Derek is on Twitter, , and Linked In

Leave a Reply