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. Visual Basic
  4. SELECT & COMPARE database column entries !

SELECT & COMPARE database column entries !

Scheduled Pinned Locked Moved Visual Basic
databasealgorithmsregextutorialquestion
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.
  • J Offline
    J Offline
    jeshra279
    wrote on last edited by
    #1

    Hi All, I have 600 rows entries in a SQL database column "Name". At present I am looping through each row and searching for a text which should match the entries in "Name" column. My code is like this: For Each dr As DataRow In myDataSet.Tables(0).Rows If Trim(dr(("Name"))) = Trim(search_text) Then ' matching found... End If Next above, myDataSet contains the "Name" column data. Now, the above code is very time consuming, because it has to loop entire 600 times... What I am looking is any simple method, by which it direct jumps into the matched row and read the entries. Can someone suggest me how to do this? Regards, R.S

    S M K 3 Replies Last reply
    0
    • J jeshra279

      Hi All, I have 600 rows entries in a SQL database column "Name". At present I am looping through each row and searching for a text which should match the entries in "Name" column. My code is like this: For Each dr As DataRow In myDataSet.Tables(0).Rows If Trim(dr(("Name"))) = Trim(search_text) Then ' matching found... End If Next above, myDataSet contains the "Name" column data. Now, the above code is very time consuming, because it has to loop entire 600 times... What I am looking is any simple method, by which it direct jumps into the matched row and read the entries. Can someone suggest me how to do this? Regards, R.S

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      have a look at these dataview examples

      1 Reply Last reply
      0
      • J jeshra279

        Hi All, I have 600 rows entries in a SQL database column "Name". At present I am looping through each row and searching for a text which should match the entries in "Name" column. My code is like this: For Each dr As DataRow In myDataSet.Tables(0).Rows If Trim(dr(("Name"))) = Trim(search_text) Then ' matching found... End If Next above, myDataSet contains the "Name" column data. Now, the above code is very time consuming, because it has to loop entire 600 times... What I am looking is any simple method, by which it direct jumps into the matched row and read the entries. Can someone suggest me how to do this? Regards, R.S

        M Offline
        M Offline
        Michel Godfroid
        wrote on last edited by
        #3

        Ever heard of the SQL 'LIKE' clause ?

        1 Reply Last reply
        0
        • J jeshra279

          Hi All, I have 600 rows entries in a SQL database column "Name". At present I am looping through each row and searching for a text which should match the entries in "Name" column. My code is like this: For Each dr As DataRow In myDataSet.Tables(0).Rows If Trim(dr(("Name"))) = Trim(search_text) Then ' matching found... End If Next above, myDataSet contains the "Name" column data. Now, the above code is very time consuming, because it has to loop entire 600 times... What I am looking is any simple method, by which it direct jumps into the matched row and read the entries. Can someone suggest me how to do this? Regards, R.S

          K Offline
          K Offline
          Kschuler
          wrote on last edited by
          #4

          The DataTable object has a .Select in which you can specify what would a WHERE portion of SQL and it will return an array of DataRows. This way you can pull a lot of data from a database just once, then filter it different ways quickly when you get it back. For your code above it would work something like this:

              For Each row As DataRow In myDataSet.Tables(0).Select("Name='" & search\_text & "'")
                  'Perform your matching found task
              Next
          
          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