完成时的 SQLBulkCopy 行计数 [英] SQLBulkCopy Row Count When Complete

查看:44
本文介绍了完成时的 SQLBulkCopy 行计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SQLBulkCopy 移动大量数据.我实现了通知事件以在每次处理一定数量的行时通知我,但在作业完成时 OnSqlRowsCopied 事件不会触发.SQLBulkCopy writetoserver 完成后如何获取复制的总行数?

I am using SQLBulkCopy to move large amounts of data. I implemented the notification event to notify me every time a certain number of rows have been processed, but the OnSqlRowsCopied event does not fire when the job is completed. How do I get the total number of rows copied when the SQLBulkCopy writetoserver completes?

推荐答案

我认为您必须在完成后对表运行 COUNT() 查询,如 MSDN 示例 此处.

I think you have to run a COUNT() query on the table after finishing, as in the MSDN example here.

除此之外,你不能提前告诉吗?例如如果您将 DataTable 传递给 WriteToServer(),那么您可以通过对其执行 .Rows.Count 来了解有多少条记录.

Other than that, can't you tell up front? e.g. if you're passing a DataTable to WriteToServer() then you know how many records by doing a .Rows.Count on it.

这篇关于完成时的 SQLBulkCopy 行计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆