Cor Ligthert [MVP]
11/17/2007 3:23:00 PM
Michael,
The "DataTable.Select is returning an array of datarows.
The dataview.ToTable is returning a datatable.
You saw my sample, I seldom do this for this kind of messages, but I made it
in the designer, that is impossible if it cannot return a table.
However because it is you I extend it a little bit.
Private Sub Form1_Load(ByVal sender As System .Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'To create a sample table
Dim dt1 As New DataTable
Dim dtc1 As New DataColumn("Michel")
Dim dtc2 As New DataColumn("Cor")
dt1.Columns.Add(dtc1)
dt1.Columns.Add(dtc2)
For i = 1 To 10
Dim dr As DataRow = dt1.NewRow
dr(0) = i.ToString & i.ToString
dr(1) = i
dt1.Rows.Add(dr)
Next
'End of building Datatable
'Therefore all you need is
dt1.DefaultView.RowFilter = "Michel > 33 And Michel < 66"
Dim dt2 As DataTable = dt1.DefaultView.ToTable(False, "Cor")
'To Show in a Grid
DataGridView1.DataSource = dt2
End Sub
The True would make a distinct table, I used 2008 beta, this overload is in
my mind not in VS2005 I thought that you need in that he new tablename as
first parameter. However you can do it for the rest exactly like this.
:-)
Cor