Here is my Scenario
I Have First Datable :TableA
**Item** **Place** ItemA PlaceA ItemB PlaceB ItemE Pla开发者_运维知识库ceE
I Have Second Datable :TableB
**Item** **Status** ------------------------------- ItemC Complete ItemD Complete ItemE Complete
Output New DataTable Will Look Like This
Item Place Status ---------------------------------------------- ItemA PlaceA ItemB PlaceB ItemC Complete ItemD Complete ItemE PlaceE Complete
Please give me the Solution in VB.Net
As a quick example:
Dim dt As New DataTable()
dt.Columns.Add("Serial", Type.GetType("System.String"))
dt.Columns.Add("Item", Type.GetType("System.String"))
dt.Columns.Add("Place", Type.GetType("System.String"))
dt.Rows.Add(New String() {"001", "ItemA", "PlaceA"})
dt.Rows.Add(New String() {"002", "ItemB", "PlaceB"})
Dim dt1 As New DataTable()
dt1.Columns.Add("Serial", Type.GetType("System.String"))
dt1.Columns.Add("Item", Type.GetType("System.String"))
dt1.Columns.Add("Status", Type.GetType("System.String"))
dt1.Rows.Add(New String() {"003", "ItemC", "Complete"})
dt1.Rows.Add(New String() {"003", "ItemD", "Complete"})
dt.Merge(dt1)
The last line is the most important, which merges the contents of one datatable with the contents of another.
Should do the trick!!
精彩评论