SQLBulkCopy used in conjunction with Transaction and firing an event each time a batch is copied

Posted by Hans Rudel on Stack Overflow See other posts from Stack Overflow or by Hans Rudel
Published on 2012-02-03T08:05:41Z Indexed on 2012/03/21 23:30 UTC
Read the original article Hit count: 272

Filed under:
|
|

Im currently uploading data to MS SQL server via SQLBulkCopy and Transactions. I would like to be able to raise an event after each batch has been uploaded (I have already tried SQLRowsCopied event and it doesnt work, see quote below)

MSDN quote:

No action, such as transaction activity, is supported in the connection during the execution of the bulk copy operation, and it is recommended that you not use the same connection used during the SqlRowsCopied event. However, you can open a different connection.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.sqlrowscopied(v=vs.80).aspx

So i basically cant have my cake and eat it :( Does anyone know a solution around this as i would like to fire an event after each batch has been uploaded.

Thanks for your help.

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql-server