2 Replies - 471 Views - Last Post: 04 February 2012 - 01:03 AM Rate Topic: -----

Topic Sponsor:

#1 scolty  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 259
  • Joined: 27-April 11

SQLBulkCopy with (Transactions & SQLRowsCopied Event)

Posted 02 February 2012 - 05:02 PM

Morning guys,

I have a general query regarding SQLBulkCopy. I would like to implement transactions with it and roll them back if there is an error during the upload for whatever reason. I would also like to have a record of which was the last batch uploaded, so i can update a winform object + tell the user where he needs to attempt to load the data from again.

Ive tried to use both Transactions and SQLRowsCopied but it doesnt work. I found this on 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.


Does anyone know of a solution around this?

Thanks for your help.

Is This A Good Question/Topic? 0
  • +

Replies To: SQLBulkCopy with (Transactions & SQLRowsCopied Event)

#2 Ionut  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 327
  • View blog
  • Posts: 914
  • Joined: 17-July 10

Re: SQLBulkCopy with (Transactions & SQLRowsCopied Event)

Posted 03 February 2012 - 11:39 AM

Have you considered to do this through a database stored procedure? In the stored procedure you build the logic and from C# you call that stored procedure and maybe other ones to get statistical data(depending on the logic)
Was This Post Helpful? 0
  • +
  • -

#3 scolty  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 259
  • Joined: 27-April 11

Re: SQLBulkCopy with (Transactions & SQLRowsCopied Event)

Posted 04 February 2012 - 01:03 AM

Morning, tbh no i hadnt actually considered that. The main purpose was to update a progressbar while the sqlbulkcopy was operating yet still have the option to rollback the batch if an error occured. When i had searched google, i hadnt come across anything that could do the above.

(my sql knowledge is pretty none existant atm)

But i will have a look into this and see if it could be a possible solution.

Thanks very much
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1