How to get difference between two DataTables

前端 未结 8 882
自闭症患者
自闭症患者 2020-12-14 17:28

I have these two datatables and I want to get the difference between them. Here is an example:

Table1
-------------------------
ID  |   Name 
---------------         


        
8条回答
  •  天命终不由人
    2020-12-14 18:02

    Try below, this is pretty basic. Merge two sets together, and get the difference. If the sets dont align up properly, then this will not work. Trying to Test the same

    DataSet firstDsData = new DataSet();
    DataSet secondDsData = new DataSet();
    DataSet finalDsData = new DataSet();
    DataSet DifferenceDataSet = new DataSet();
    finalDsData.Merge(firstDsData);
    finalDsData.AcceptChanges();
    finalDsData.Merge(secondDsData);
    DifferenceDataSet = finalDsData.GetChanges();
    

提交回复
热议问题