jjzjj

BeginExecuteNonQuery

全部标签

c# - 没有 EndExecuteNonQuery 的 BeginExecuteNonQuery

我有以下代码:using(SqlConnectionsqlConnection=newSqlConnection("blahblah;AsynchronousProcessing=true;"){using(SqlCommandcommand=newSqlCommand("someProcedureName",sqlConnection)){sqlConnection.Open();command.CommandType=CommandType.StoredProcedure;command.Parameters.AddWithValue("@param1",param1);comma

c# - 使用相同的 SqlConnection 对 SqlCommand.BeginExecuteNonQuery 的多个并发调用

我有一些工作的C#代码使用SqlConnection创建临时表(例如,#Foo),调用存储过程来填充这些临时表并将结果返回到C#客户端,使用c#对这些结果执行复杂的计算,并使用计算结果更新之前创建的其中一个临时表。由于在整个过程中使用临时表,我们必须只有一个SqlConnection。我发现了用计算结果更新临时表的性能瓶颈。此代码已对更新进行批处理,以防止C#客户端内存不足。每批计算数据都通过SqlCommand.ExecuteNonQuery发送到存储过程,存储过程依次更新临时表。代码大部分时间都花在调用ExecuteNonQuery上。因此,我将其更改为BeginExecuteNo