Header Ads

  • Breaking News

    VB.NET program that uses DataTable, Select

    VB.NET program that uses DataTable, Select 
     
    Module Module1
    
        Sub Main()
     ' Create a table.
     Dim table As DataTable = New DataTable("Players")
    
     ' Add two columns.
     table.Columns.Add(New DataColumn("Size", GetType(Integer)))
     table.Columns.Add(New DataColumn("Sex", GetType(Char)))
    
     ' Add five rows.
     table.Rows.Add(100, "f"c)
     table.Rows.Add(235, "f"c)
     table.Rows.Add(250, "m"c)
     table.Rows.Add(310, "m"c)
     table.Rows.Add(150, "m"c)
    
     ' Get players above 230 size with "m" sex.
     Dim result() As DataRow = table.Select("Size >= 230 AND Sex = 'm'")
    
     ' Loop and display.
     For Each row As DataRow In result
         Console.WriteLine("{0}, {1}", row(0), row(1))
     Next
        End Sub
    
    End Module
    
    Output
    
    250, m
    310, m

    ที่มา http://www.dotnetperls.com/datatable-select-vbnet

    ไม่มีความคิดเห็น

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728