How to merge multiple dataviews into one?

天涯浪子 提交于 2019-12-08 19:10:55

问题


I have three dataviews (dataview1, dataview2, and dataview3). These are of type System.Data.DataView, and all three have the same columns. Is there an easy way to merge them into one, so I have one dataview with rows from dataview1, followed by dataview2, and then dataview3?


回答1:


Dim dataview1 As DataView = new DataView()
Dim dataview2 As DataView = new DataView()

'' given the tables are not null you can then merge like this

dataview1.Table.Merge(dataview2.Table)



回答2:


DataTable datatableMerge = dataview1.ToTable();
datatableMerge.Merge(dataview2.ToTable());

The result includes only the rows according to the the DataViews' Filters.



来源:https://stackoverflow.com/questions/7614150/how-to-merge-multiple-dataviews-into-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!