I am getting this error microsoft.sqlserver.jdbc.SQLServerException: 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.
im new to coding stuffs, i know that i am passing morethan 2100 parameter that is why the error is encountered.
Can someone help me to find better solution or approach so that i can resolve the error?
Thank you very much.
Here is the actual code.
Public Sub New(ByRef messages As List(Of SomeMessage))
Dim count As Integer = 0
Dim sb As StringBuilder = New StringBuilder()
sb.AppendLine(" INSERT INTO Table1 ")
sb.AppendLine(" (Id ")
sb.AppendLine(" ,UniqueNbr ")
sb.AppendLine(" ,ClockId ")
sb.AppendLine(" ,TypeNmber")
sb.AppendLine(" ,CurrencyAmt ")
sb.AppendLine(" ,CurrencyCd ")
sb.AppendLine(" ,MemberId ")
sb.AppendLine(" ,CreateDttm ")
sb.AppendLine(" ,UpdateMemberId ")
sb.AppendLine(" ,UpdateDttm) ")
For Each abc As SomeMessage In messages
count += 1
sb.AppendLine(" Select ")
sb.AppendLine(" @Id" + count.ToString())
sb.AppendLine(" ,@UniqueNbr " + count.ToString())
sb.AppendLine(" ,@ClockId " + count.ToString())
sb.AppendLine(" ,@TypeNmber" + count.ToString())
sb.AppendLine(" ,@CurrencyAmt" + count.ToString())
sb.AppendLine(" ,@CurrencyCd" + count.ToString())
sb.AppendLine(" ,@MemberId " + count.ToString())
sb.AppendLine(" ,@CreateDttm" + count.ToString())
sb.AppendLine(" ,@UpdateMemberId " + count.ToString())
sb.AppendLine(" ,@UpdateDttm" + count.ToString())
sb.AppendLine(" UNION ALL")
Me.Parameters.Add(Me.CreateParameter("@Id" + count.ToString(), DbType.Int32, abc.Id, ParameterDirection.Input))
Me.Parameters.Add(Me.CreateParameter("@UniqueNbr " + count.ToString(), DbType.Int32, abc.UniqueNbr, ParameterDirection.Input))
Me.Parameters.Add(Me.CreateParameter("@ClockId" + count.ToString(), DbType.Int32, abc.ClockId, ParameterDirection.Input))
Me.Parameters.Add(Me.CreateParameter("@TypeNmber" + count.ToString(), DbType.Int32, abc.TypeNmber, ParameterDirection.Input))
Me.Parameters.Add(Me.CreateParameter("@CurrencyAmt" + count.ToString(), DbType.Decimal, abc.CurrencyAmt, ParameterDirection.Input))
Me.Parameters.Add(Me.CreateParameter("@CurrencyCd" + count.ToString(), DbType.String, abc.CurrencyCd, ParameterDirection.Input))
Me.Parameters.Add(Me.CreateParameter("@MemberId" + count.ToString(), DbType.String, abc.MemberId, ParameterDirection.Input))
Me.Parameters.Add(Me.CreateParameter("@CreateDttm" + count.ToString(), DbType.Date, abc.CreateDttm, ParameterDirection.Input))
Me.Parameters.Add(Me.CreateParameter("@UpdateMemberrId" + count.ToString(), DbType.String, abc.UpdateMemberrId, ParameterDirection.Input))
Me.Parameters.Add(Me.CreateParameter("@UpdateDttm" + count.ToString(), DbType.Date, abc.UpdateDttm, ParameterDirection.Input))
Next
Me.Sql = sb.ToString().Trim().TrimEnd("UNION ALL".ToCharArray())
Me.KeyParameter = "@TabletCompletionId"
End Sub