How to get data of one or two column from dataset in vb.net

Suppose if you want to retrieve only one column or some specific columns from dataset or datatable. How can you do it. Is it possible?
Yes it is possible and you can do it in very simple way. On here i am describing how we can retrieve some specific column data from the dataset.

I am assuming that we have a dataset ds and there are two columns ‘Age‘ and ‘department‘ in the dataset and we want to get the data of both columns. Than you can use the following code:
 

    Private Function GetDataFrom_SpecificColumn(ByVal strColumns As String, _
           ByVal ds As DataSet) As DataTable
        Dim dt As New DataTable
        Dim dv As New DataView
        Dim keyArr As String() = strColumns.Split(",")
        dv = ds.Tables(0).DefaultView
        dt = dv.ToTable(False, keyArr)
        Return dt
    End Function

How to use the following function:
we need pass comma separated columns names and dataset into the function. see this:
 

Dim dt as datatable = GetDataFrom_SpecificColumn("Age,Department",ds)

from above datatable dt will contains only two columns ‘Age and department‘.