Avoid duplicate records while merging DataTables

You can achieve this by just defining the Primary key of targetTable.
DataTable TargetTable;
DataTable Table1;
//  write code to create/fill target table
TargetTable= GetTargetTable();
// define primary key
// for multiple columns
TargetTable.PrimaryKey= new DataColumn[]{TargetTable.Columns[columnName_1],TargetTable.Columns[columnName_2],TargetTable.Columns[columnName_3]};
// for single column
TargetTable.PrimaryKey= new DataColumn[]{TargetTable.Columns[columnName_1]);

// get records�
Table1= GetTable1();
// define primary key
// — same as above
// merge records into TargetTable

Continue ReadingAvoid duplicate records while merging DataTables