SqlRowsCopied event in SqlBulkCopy + .NET 2.0

Hi All,

I'm using SqlBulkCopy class to copy the records from One table to another table. I want to count the no. of records copied during the bulkcopy. I tried with using SqlRowsCopied event, but it seems like the event will get trigger only based on NotifyAfter property i.e by setting a value for NotifyAfter.

I dont want this to happen using NotifyAfter property, instead the event should get fired after all the records copied to the destination table.

please share your ideas on this...

Regards,
Prabhu

[545 byte] By [PrabhuRS] at [2007-12-24]
# 1
You are correct that the current functionality of SqlRowsCopied event does not allow you to recieve a notification only at the end without knowing the total number of rows that will be processed ahead of time. I will add this to our wish-list for future functionality.

You can set up an event that keeps a sum of the number of rows sent and use that value once the bulk copy is complete. To get an accurate count, you would have to set NotifyAfter to 1, since the event is not currently sent for the last set of rows unless the number in that set equals the NotifyAfter value.

alazela at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified