Reputation: 159
I have a Dataset There are five columns in the set. I need to get the value in each row in one single column - for example: The value of each row in Column A.
How would I do this?
UPDATE: Im sorry if I wasn't clear. I'm new to DB style programming, but I pick up on examples fast for learning.
I have a Dataset populated with 5 columns and an unknown number of records (rows) past row 4. I need to populate a menu with everything past row 4 in the second (name) column.
DB Example:
id|name|etc|etc|etc
1 |this|etc|etc|etc and on...
Upvotes: 0
Views: 1848
Reputation: 29026
Let dt
be your Datatable
having columns id
and name
and you are going to select all records of column name
then the following code will help you:
Dim dt As New DataTable
dt.Columns.Add("id")
dt.Columns.Add("name")
'populating datatable
For i As Integer = 0 To 10
Dim dr As DataRow = dt.NewRow
dr("id") = i.ToString
dr("name") = "a" & i.ToString
dt.Rows.Add(dr)
Next
' result
Dim selectedCols = New DataView(dt).ToTable(False, "name")
Upvotes: 1