HOW TO SELECT SPECIFIC COLUMNS FROM A DATA TABLE IN VB.NET?

sandy taylor

Total Post:46

Points:324
Posted by  sandy taylor
VB.Net 
 1371  View(s)
Ratings:
Rate this:

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

  1. Ankit Singh

    Post:341

    Points:2389
    Re: how to select specific columns from a data table in vb.net?

    Dim view As New DataView(MyDataTable)

    Dim distinctValues As DataTable = view.ToTable(True, "ColumnA")

  1. Tanuj Kumar

    Post:134

    Points:940
    Re: how to select specific columns from a data table in vb.net?

    Try like This

     

    TempDt =New DataView(Rows.CopyToDataTable()).ToTable(False,

    "columnname1", "name2","...","..")

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!