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?
+1
A:
I think you have to run a COUNT() query on the table after finishing, as in the MSDN example here.
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.
AdaTheDev
2009-07-27 14:20:13
and if you are using an IDataReader you can just wrap it, there should never really be a need to call count but its a hack that can work
Sam Saffron
2009-07-27 22:30:22