我有一个数据表,我根据条件从中过滤数据,但是如何仅显示数据表中的特定列?
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
答案 0 :(得分:1)
Dim view As New DataView(MyDataTable)
Dim distinctValues As DataTable = view.ToTable(True, "ColumnA")
答案 1 :(得分:0)
试试这个
TempDt =New DataView(Rows.CopyToDataTable()).ToTable(False,
"columnname1", "name2","...","..")