How to get difference between two DataTables

前端 未结 8 889
自闭症患者
自闭症患者 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:13

    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.

    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();
    

提交回复
热议问题