Last post Sep 09, 2016 04:10 AM by Yohann Lu
Sep 08, 2016 10:46 AM|maheshvishnu|LINK
I have 2 dataviews named dv1,dv2
after calling dv1.Table.Merge(dv2.Table) i am loosing data in dv1. here i have same structure in both dv1 and dv2
how to merge 2 dataviews?
Sep 08, 2016 11:12 AM|Siva Krishna Macha|LINK
1. Is the missing data is for the child tables? If so:
See these notes from MSDN:
The merge operation takes into account only the original table, and the table to be merged. Child tables are not affected or included. If a table has one or more child tables, defined as part of a relationship, each child table must be merged individually.
2. It's worth to check the states once as per this note:
When merging a new source DataTable into the target, any source rows with a DataRowState value
of Unchanged, Modified, orDeleted, is matched to target rows with the same primary key values. Source rows with a DataRowState value
of Added are matched to new target rows with the same primary key values as the new source rows.
Sep 09, 2016 04:10 AM|Yohann Lu|LINK
DataView itself just view, you can merge two DataTable into one, and then returns a DataView to achieve this.
The Merge method takes the values from the second table and merges them in with the first table, so the first will now hold the values from both.
DataView dv = new DataView();
DataView dv1 = new DataView();
DataTable dTable = dv.ToTable();
DataTable dTable1 = dv1.ToTable();
You could also share us more relevant code to help us reproduce the problem.