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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to filter?

How to filter?

Scheduled Pinned Locked Moved Database
tutorialquestion
14 Posts 5 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.
  • S Offline
    S Offline
    shyne7
    wrote on last edited by
    #1

    I want to filter my data while im typing the word that i want to search on a textbox.tnx Sunshine

    C R 2 Replies Last reply
    0
    • S shyne7

      I want to filter my data while im typing the word that i want to search on a textbox.tnx Sunshine

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Where is your data coming from ? It seems pretty straightforward to me, if you're using a database and want to filter from the DB. Just build a query on each keypress to return the data valid for that search.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      S 1 Reply Last reply
      0
      • C Christian Graus

        Where is your data coming from ? It seems pretty straightforward to me, if you're using a database and want to filter from the DB. Just build a query on each keypress to return the data valid for that search.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        S Offline
        S Offline
        shyne7
        wrote on last edited by
        #3

        yes im using a database and the search result would appear to the gridview...im having a combobox that would give the textbox choices on which to filter...but i dont know how to use the like clause in the select statement propely.. sql = "Select Supplier_Information.Supplier_ID,Supplier_Information.Supplier_Name,Supplier_Information.Address,Supplier_Information.Contact_No, Products.Product_ID, Products.Product_Name,Products.Product_Type, Products.Present_Price, Products.Past_Price from Supplier_Information, Products where Supplier_Information.Supplier_ID like '%s-%' " i have this code but it does not work properly...i want to come up with a textbox that would filter in every letter that they will type in the textbox.tnx

        P 1 Reply Last reply
        0
        • S shyne7

          yes im using a database and the search result would appear to the gridview...im having a combobox that would give the textbox choices on which to filter...but i dont know how to use the like clause in the select statement propely.. sql = "Select Supplier_Information.Supplier_ID,Supplier_Information.Supplier_Name,Supplier_Information.Address,Supplier_Information.Contact_No, Products.Product_ID, Products.Product_Name,Products.Product_Type, Products.Present_Price, Products.Past_Price from Supplier_Information, Products where Supplier_Information.Supplier_ID like '%s-%' " i have this code but it does not work properly...i want to come up with a textbox that would filter in every letter that they will type in the textbox.tnx

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          Whoah - this is a really bad design. Don't attempt to do this because you are going to be hitting the database after every keypress. The more users you have, the more you are going to hit the database. How would you handle the case where the user enters some text and then starts to delete text? Thats the same data being queried many times. Please - rethink your design.

          Deja View - the feeling that you've seen this post before.

          S 1 Reply Last reply
          0
          • P Pete OHanlon

            Whoah - this is a really bad design. Don't attempt to do this because you are going to be hitting the database after every keypress. The more users you have, the more you are going to hit the database. How would you handle the case where the user enters some text and then starts to delete text? Thats the same data being queried many times. Please - rethink your design.

            Deja View - the feeling that you've seen this post before.

            S Offline
            S Offline
            shyne7
            wrote on last edited by
            #5

            any suggestive design that i could make?may i know exacly what is the bad design that you are pertaining of...tnx

            P 1 Reply Last reply
            0
            • S shyne7

              any suggestive design that i could make?may i know exacly what is the bad design that you are pertaining of...tnx

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              I'm sorry, but I thought I'd made myself clear enough. Don't design a system where you are hitting the database so many times. Apart from anything else, you probably won't be able to retrieve the data and display it quickly enough if the user is a quick typist. As for the design - identify a more natural point for retrieving the data.

              Deja View - the feeling that you've seen this post before.

              S 1 Reply Last reply
              0
              • P Pete OHanlon

                I'm sorry, but I thought I'd made myself clear enough. Don't design a system where you are hitting the database so many times. Apart from anything else, you probably won't be able to retrieve the data and display it quickly enough if the user is a quick typist. As for the design - identify a more natural point for retrieving the data.

                Deja View - the feeling that you've seen this post before.

                S Offline
                S Offline
                shyne7
                wrote on last edited by
                #7

                should i delete my combobox?or can i search any data on my database in my textbox without giving any choices for filtering

                P 1 Reply Last reply
                0
                • S shyne7

                  should i delete my combobox?or can i search any data on my database in my textbox without giving any choices for filtering

                  P Offline
                  P Offline
                  Pete OHanlon
                  wrote on last edited by
                  #8

                  This has stopped being a question about databases and become a question about an autofiltering combo box. The exact details of how to do this depends on whether you are using Win Forms or ASP.NET.

                  Deja View - the feeling that you've seen this post before.

                  S 1 Reply Last reply
                  0
                  • P Pete OHanlon

                    This has stopped being a question about databases and become a question about an autofiltering combo box. The exact details of how to do this depends on whether you are using Win Forms or ASP.NET.

                    Deja View - the feeling that you've seen this post before.

                    S Offline
                    S Offline
                    shyne7
                    wrote on last edited by
                    #9

                    i using vb.net...actually i really want to know about filtering...hos to use the like clause for searching

                    C 1 Reply Last reply
                    0
                    • S shyne7

                      I want to filter my data while im typing the word that i want to search on a textbox.tnx Sunshine

                      R Offline
                      R Offline
                      rohitsrivastava
                      wrote on last edited by
                      #10

                      u want to filter so , u are writing the query. ok then in where clause fieldname like '" & textbox1.text & "%' u will get the result

                      S C 2 Replies Last reply
                      0
                      • R rohitsrivastava

                        u want to filter so , u are writing the query. ok then in where clause fieldname like '" & textbox1.text & "%' u will get the result

                        S Offline
                        S Offline
                        shyne7
                        wrote on last edited by
                        #11

                        tnx...that helps...but i have two tables in one gridview...how could i view those in my gridview when i search for a data that is only in one of the tables

                        1 Reply Last reply
                        0
                        • S shyne7

                          i using vb.net...actually i really want to know about filtering...hos to use the like clause for searching

                          C Offline
                          C Offline
                          Colin Angus Mackay
                          wrote on last edited by
                          #12

                          shyne7 wrote:

                          i using vb.net

                          VB.NET is a language. The question was about frameworks. Which framework are you using? The ASP.NET framework or the WinForms framework (both of which are part of the larger .NET Framework)

                          shyne7 wrote:

                          hos to use the like clause for searching

                          WHERE SomeColumn LIKE '%'+@SomeSearchTerm+'%'

                          @SomeSearchTerm is passes as a parameter for security


                          Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                          1 Reply Last reply
                          0
                          • R rohitsrivastava

                            u want to filter so , u are writing the query. ok then in where clause fieldname like '" & textbox1.text & "%' u will get the result

                            C Offline
                            C Offline
                            Colin Angus Mackay
                            wrote on last edited by
                            #13

                            rohitsrivastava wrote:

                            fieldname like '" & textbox1.text & "%'

                            NO NO NO NO!!!! Do NOT inject into SQL strings like this. I've been banging on about this for THREE years now! Doesn't anyone know about SQL Injection Attacks?! SQL Injection Attacks and Tips on How to Prevent Them[^]


                            Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                            P 1 Reply Last reply
                            0
                            • C Colin Angus Mackay

                              rohitsrivastava wrote:

                              fieldname like '" & textbox1.text & "%'

                              NO NO NO NO!!!! Do NOT inject into SQL strings like this. I've been banging on about this for THREE years now! Doesn't anyone know about SQL Injection Attacks?! SQL Injection Attacks and Tips on How to Prevent Them[^]


                              Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                              P Offline
                              P Offline
                              Pete OHanlon
                              wrote on last edited by
                              #14

                              Ah well - at least I did mention parameterized queries (albeit in another post):-D. Don't worry Colin - some of the more professional members of the site have read/taken in your message. Perhaps your technical test should include a query that's wide open for Sql Injection and then ask candidates if they can tell you what's wrong with it.

                              Deja View - the feeling that you've seen this post before.

                              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