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. Database & SysAdmin
  3. Database
  4. Select from a DataTable

Select from a DataTable

Scheduled Pinned Locked Moved Database
databaseregextutorial
4 Posts 2 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
    MohammadAmiry
    wrote on last edited by
    #1

    I have a DataSet which has Two tables: TableAll, TableQueried TabelAll has all data available. What I want is to use a command to select only those rows in TableAll and copy them to TabelQueried which are LIKE some pattern. I knew how to do this when I had a database and used connections; but now there is no database. How should I do anything like this command: "SElECT * FROM TABELALL WHERE Data LIKE [pattern]"

    A 1 Reply Last reply
    0
    • M MohammadAmiry

      I have a DataSet which has Two tables: TableAll, TableQueried TabelAll has all data available. What I want is to use a command to select only those rows in TableAll and copy them to TabelQueried which are LIKE some pattern. I knew how to do this when I had a database and used connections; but now there is no database. How should I do anything like this command: "SElECT * FROM TABELALL WHERE Data LIKE [pattern]"

      A Offline
      A Offline
      Aaron VanWieren
      wrote on last edited by
      #2

      I assume you are talking about an ADO.NET way? If so look at DataTable.Select(CriteriaString). I think the select method has an override for an order by clause. Criteriastring is a string in the format of: (column name) expressions such as = or like or in; google datatable.select to get list of expressions. And then the criteria, very similar to a where condition in a sql statement. IE for examaple

      DataRow[] rows = myDataTable.Select("Column1 = 25","column1 asc")

      This will return an array of DataRows which you can then work with. Hope this helps! Aaron

      _____________________________________________________________________ Our developers never release code. Rather, it tends to escape, pillaging the countryside all around. The Enlightenment Project (paraphrased comment) Visit Me at GISDevCafe

      M 1 Reply Last reply
      0
      • A Aaron VanWieren

        I assume you are talking about an ADO.NET way? If so look at DataTable.Select(CriteriaString). I think the select method has an override for an order by clause. Criteriastring is a string in the format of: (column name) expressions such as = or like or in; google datatable.select to get list of expressions. And then the criteria, very similar to a where condition in a sql statement. IE for examaple

        DataRow[] rows = myDataTable.Select("Column1 = 25","column1 asc")

        This will return an array of DataRows which you can then work with. Hope this helps! Aaron

        _____________________________________________________________________ Our developers never release code. Rather, it tends to escape, pillaging the countryside all around. The Enlightenment Project (paraphrased comment) Visit Me at GISDevCafe

        M Offline
        M Offline
        MohammadAmiry
        wrote on last edited by
        #3

        THANK YOU!! ;) You really helped me out! :rose: I was JUST looking for this.

        A 1 Reply Last reply
        0
        • M MohammadAmiry

          THANK YOU!! ;) You really helped me out! :rose: I was JUST looking for this.

          A Offline
          A Offline
          Aaron VanWieren
          wrote on last edited by
          #4

          The only caveat you need to remember is that the datatable select consumes quite a bit of memory as it has to go through every record in the table. Be sure to set a primary key column and index if possible. Aaron

          _____________________________________________________________________ Our developers never release code. Rather, it tends to escape, pillaging the countryside all around. The Enlightenment Project (paraphrased comment) Visit Me at GISDevCafe

          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