Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Selecting from datatable

Selecting from datatable

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    myinstincts
    wrote on last edited by
    #1

    I want to select "FullName","EmployeeNumber" from the datatable 'results' ..The selection should be based on some conditions like date=some date....Can anybody tell how to achieve this???

    G D A 3 Replies Last reply
    0
    • M myinstincts

      I want to select "FullName","EmployeeNumber" from the datatable 'results' ..The selection should be based on some conditions like date=some date....Can anybody tell how to achieve this???

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      Datatable has a method Select which does what it says but I am not sure whether it allows filtering or not. If I remember correctly you can use DataView to filter data.

      Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion

      1 Reply Last reply
      0
      • M myinstincts

        I want to select "FullName","EmployeeNumber" from the datatable 'results' ..The selection should be based on some conditions like date=some date....Can anybody tell how to achieve this???

        D Offline
        D Offline
        dan sh
        wrote on last edited by
        #3

        If you are using .Net 3.0 or above, LINQ is your friend. Otherwise, you can use DataTable.Select method to get the rows which fulfill the conditions and then extract the name and employee numbers from them. If this is a one time activity ie conditions are pre defined and well known, the fetch only the data that confirms the conditions. You can have a stored procedure which can take the date values as parameter and then return the records.

        50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

        1 Reply Last reply
        0
        • M myinstincts

          I want to select "FullName","EmployeeNumber" from the datatable 'results' ..The selection should be based on some conditions like date=some date....Can anybody tell how to achieve this???

          A Offline
          A Offline
          Anurag Gandhi
          wrote on last edited by
          #4

          Try objTable.Select("date='some date'");

          Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups