Ackumulating data from multiple DataSets to a DataGridView
I am new to VB.NET and ADO.Net and need some advice. Is it possible to ackumulate data from multiple DataSets to a single DataGridView? My application spawns multiple DataSets, each beeing the DataSource for a single, unique DataGridView. All DataSets have 4 fields with similar data (not the same data, though). I would like to collect these data to a single DataSet that I can make the DataSource for a new DataGridView. Is it possible and how do I do? Any hint in the right direction would be appreciated.
Hi,
You could do that by pragmatically creating a dataset, datatable and fields and manually filling it up with the values in your 4 datasets...
Dim ds as new DataSet
Dim dt as new DataTabledt.Columns.Add(New DataColumn("Field1", System.Type.GetType("System.Int32"))
dt.Columns.Add(New DataColumn("Field2", System.Type.GetType("System.Int32"))
...
ds.Tables.Add(dt)
For i = 0 to ds1.Tables(0).Rows.Count - 1
Dim newRow as DataRow
newRow = dt.NewRow()
newRow("Field1") = ds1.Tables(0).Rows(i)("Field1")
...
Next i
For i = 0 to ds2.Tables(0).Rows.Count - 1
Dim newRow as DataRow
newRow = dt.NewRow()
newRow("Field1") = ds1.Tables(0).Rows(i)("Field1")
...
Next i
...
BTW, I ain't got no VB here in front of me right now. That is just the logic, so just modify it to suit your need...
cheers,
Paul June A. Domag