C# 传递大表值参数时超时

C# 传递大表值参数时超时,c#,sql-server,ado.net,timeout,table-valued-parameters,C#,Sql Server,Ado.net,Timeout,Table Valued Parameters,我使用ADO.NET调用SQL Server存储过程,并且必须传递一个非常大的表值参数。我经常遇到这种超时异常: System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.

我使用ADO.NET调用SQL Server存储过程,并且必须传递一个非常大的表值参数。我经常遇到这种超时异常:

System.Data.SqlClient.SqlException (0x80131904): Timeout expired.
The timeout period elapsed prior to completion of the operation or the server is not responding. --->
System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out   at System.Data.SqlClient.SqlCommand.EndExecuteNonQueryAsync(IAsyncResult asyncResult)
我正在调用
ExecuteOnQueryAsync
,根据,它不受命令超时的影响


问题是:我应该增加什么样的超时值才能将这么大的TVP传递给存储过程而不需要超时?

最近帮助我解决这个问题的一个解决方案是增加连接超时(不要误认为是命令超时)。这使我想到,有时当有大量数据通过表值参数传递到存储过程时,初始化连接的时间可能会更长(这发生在峰值使用期间,但不是在系统处于低负载时)。增加连接超时的一种简单方法是通过查询字符串

将超时设置为120秒而不是默认的15秒的示例:

"Data Source=localhost;Integrated Security=SSPI;Connection Timeout=120;"

“我必须传递一个非常大的表值参数”-您必须用C#代码构造这个表,还是可以在过程中实现它?我必须用C#构造它,所有这些都是数据库的新输入(有点像批量操作)。