我目前正在使用SQL Server 2014中的C#脚本更新和读取值.当使用SQlCommand执行InitQuery时,它会在运行脚本时弹出错误:
IndexOutOfRangeException:数组索引超出范围.
Mono.Data.Tds.Protocol.TdsComm.AppendInternal(Int16 s)
Mono.Data.Tds.Protocol.TdsComm.Append(System.String s)
Mono.Data.Tds.Protocol.Tds70.WriteRpcParameterInfo(Mono.Data.Tds. TdsMetaParameterCollection参数)
Mono.Data.Tds.Protocol.Tds70.ExecRPC(TdsRpcProcId rpcId,System.String sql,Mono.Data.Tds.TdsMetaParameterCollection参数,Int32超时,布尔值wantResults)
Mono.Data.Tds.Protocol.Tds70.Execute( System.String commandText,Mono.Data.Tds.TdsMetaParameterCollection参数,Int32 timeout,Boolean wantResults)
System.Data.SqlClient.SqlCommand.Execute(Boolean wantResults)
System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
(wrapper remoting-invoke- with-check)
System.Data.SqlClient.SqlCommand:ExecuteNonQuery()
Database.DataBaseConnection.Update()(在Assets/DataBaseConnection.cs:674)
我计算了SqlCommand它有多少个字符,它是8,125个字符(没有空格),10,874个字符(带空格).
有198个参数,但我想这不是由于那个,因为在某处我读到单个查询的最大参数量是2000,我是对的吗?
我减少了参数的数量(直到20个参数),因此,命令长度和它的作用就像一个魅力(875个字符没有空格和1,221个字符带空格).
总而言之,我的问题是:SqlCommandSQL Server 2014中查询的最大长度是多少?在SQL Server 2008中?
我的代码示例:
//New command to update values in input table in sql server
using (SqlCommand command = new SqlCommand("UPDATE DigitalInputs" +
" SET Value = CASE Name" +
" WHEN @LI_Input_Variable1_Name THEN @LI_Input_Variable1_Value" +
" WHEN @LI_Input_Variable2_Name THEN @LI_Input_Variable2_Value" +
" WHEN @LI_Input_Variable3_Name …Run Code Online (Sandbox Code Playgroud) sql sql-server monodevelop unity-game-engine executenonquery