Difference between two data tables

Posts   
 
    
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 08-Aug-2011 22:03:16   

Hi guys, question has nothing to do with llblgen other than a method that is used to create table1. thought this is a good spot to ask such a question since there are many experts here.

i have a situation in which i have to find the difference between two datatables. i have used the following:

DataTable table1= GetTable1AsDataTable(); var keys = new DataColumn[2]; keys[0] = table1.Columns["StudentId"]; keys[1] = table1.Columns["ChecklistItemId"]; table1.PrimaryKey = keys;

        DataTable table2= table1.Clone();

now here i have the code to fill the table2. finally i do this:

table1.AcceptChanges(); table1.Merge(table2); return table1.GetChanges();

debugging: table1 returns 30 rows table2 returns 2000 rows including the ones in table1 and my method returns 2000 rows and not 1970.
i have tried .Merge with .Merge(table2,true) and .Merge(table2,false) but nothing seems to work.

what am i missing here? thanks in advance

-shane