how to select specific columns from a data table in vb.net?

15,312
Dim view As New DataView(MyDataTable)
Dim distinctValues As DataTable = view.ToTable(True, "ColumnA")
Share:
15,312
sona
Author by

sona

Updated on June 04, 2022

Comments

  • sona
    sona almost 2 years

    I have a data table from which i am filtering data based on condition,but how to display specific columns only from the data table?

    Dim Dt As New DataTable
                    Dim SQlDa As SqlDataAdapter = New SqlDataAdapter(SqlCmd)
                    SQlDa.Fill(TrackingDt)
                    Dim Rows() As DataRow = Dt.Select("State = " + "'" + State + "'")
                    Dim TempDt As New DataTable
                    If Rows.Length > -1 Then
                        TempDt = Rows.CopyToDataTable()
                    End If
    
    
                    Return TempDt 
    
  • Rohit Paul
    Rohit Paul about 10 years
    If i want to select multiple columns and filter distinct by a specific column, how should i do it?