I am trying to design a window based application in C#.NET. I am reading csv file in data grid view and then insert those data into database. I am using
SqlBulkCopy to insert data from csv file into database. My concern is, when I am trying to insert data into database (which already consist data) I am getting error of primary key constraint. I want to know whether it is possible to compare value before inserting into database using
SqlBulkCopy. If value exist in database it should do update.
Can anyone provide me logic for this.
If you really, really know that the dupes aren't needed, just set the "Ignore Dupes" option on the index for the PK and you're done.