Workaround "The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect" error.

We have a .Net 1.1 application that worked with SQL server 2000. When we changed it to work with sql Server 2005, some calls to SPs returned errors like the following

"The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 8 ("@ParamName"): The supplied value is not a valid instance of data type numeric. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision."

It was found, that C# decimal variable can keep values with more than 4 decimal points (e.g. 43.23232322323) and when it is passes to SP parameter as MONEY, combination .Net 1.1 - SQL Server 2005 doesn't work.
Note that combination  .Net 1.1 - SQL Server 2000 and  .Net 2.0 - SQL Server 2005  work fine.

To workaround I've added simple function to round values before assigning SP parameter

       public static decimal SafeMoney(object attribute)
        {
            decimal decMoney = Convert.ToDecimal(attribute);
            decMoney = Math.Round(decMoney, 4);//required in 1.1 to connect to SQL Server 2005
           return decMoney;
        }

 

 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted @ Wednesday, June 20, 2007 12:45 AM
Print

Comments on this entry:

# re: Workaround "The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect" error.

Left by Mads Neve at 1/13/2009 10:52 PM
Gravatar
Thanks for det workaround, worked perfectly...

# re: Workaround "The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect" error.

Left by Duvadesa at 3/18/2009 7:55 PM
Gravatar
When you use SqlDbType.Decimal instead of DbType.Decimal the problem is also solved, with less impact.

# re: Workaround "The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect" error.

Left by Felipe at 12/17/2010 5:32 AM
Gravatar
Is it possible to solve that by doing something in the database not in the code?

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910