G
G .Net
Hi
I'm wondering if anybody can help me with the following problem?
I have a table with several rows. I want to create a new table, with exactly
the same structure, but has only a subset of the rows in the original table.
I have been able to do this using the following code but wonder if there is
a more efficient/fast way of doing it.
Dim subsetTable As DataTable = sourceTable.Clone()
For Each row As DataRow In sourceTable.Select("[Name] = 'John'")
Dim newRow As DataRow = subsetTable.NewRow()
For i As Integer = 0 To sourceTable.Columns.Count - 1
newRow(i) = row(i)
Next
subsetTable.Rows.Add(newRow)
Next
Using the code above I can a new table which has all the rows from the
source table with the field "Name" set to "John".
Can anybody suggest a more efficient/fast way of doing this?
Thanks in advance
I'm wondering if anybody can help me with the following problem?
I have a table with several rows. I want to create a new table, with exactly
the same structure, but has only a subset of the rows in the original table.
I have been able to do this using the following code but wonder if there is
a more efficient/fast way of doing it.
Dim subsetTable As DataTable = sourceTable.Clone()
For Each row As DataRow In sourceTable.Select("[Name] = 'John'")
Dim newRow As DataRow = subsetTable.NewRow()
For i As Integer = 0 To sourceTable.Columns.Count - 1
newRow(i) = row(i)
Next
subsetTable.Rows.Add(newRow)
Next
Using the code above I can a new table which has all the rows from the
source table with the field "Name" set to "John".
Can anybody suggest a more efficient/fast way of doing this?
Thanks in advance