This SqlTransaction has completed; it is no longer usable

南笙酒味 提交于 2019-12-05 07:50:51

SubmitChanges has an implicit transaction. The problem here that your transaction is timing out - you are simply doing too much. For 200k rows I would use SqlBulkCopy into a staging table, and then run a command or SPROC to move that 200k into the actual table; perhaps with that command/SPROC in a transaction.

SqlBulkCopy is designed for this scenario - it is one continuous stream or raw TDS data, rather than however-may round-trips - and at the server end it is optimised too (but as a consequence, you must use a staging table, or you risk the inserts being non-logged).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!