Reputation: 13983
While bulk inserting thousands of records I get exception with the message 'Foreign key constraint violation'.
Unfortunately message provides no clues to the records with bad data.
Are there any tricks which allow to get more detailed information about the problem? Otherwise debugging such issues is a real pain.
Upvotes: 1
Views: 122
Reputation: 473
I believe you could add a handler for the OnRowUpdated event, where you could check for an error and look at information about the specific row.
See this answer for an example as a starting point: How to track which row update failed in batch update
For SqlBulkCopy check out this CodeProject article: http://www.codeproject.com/Articles/387465/Retrieving-failed-records-after-an-SqlBulkCopy-exc
Upvotes: 2