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. Using Wild Character _ [modified]

Using Wild Character _ [modified]

Scheduled Pinned Locked Moved C#
database
11 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.
  • U Offline
    U Offline
    User 4547220
    wrote on last edited by
    #1

    Hi, I have a following file names in my database. TestDocument _ 1 _ 0 TestDocument _ Evidence Test45 123_publish when i am entering the Test_ in the DocumentName textbox it is forst converted to uppercase and send to the query and query has following expression which returns all record where it should not have to return any record. please tell me the changes in the following expression. UPPER(DOC.ORIGINAL_FILE_NAME) like '%TEST_%' Thanks, Umesh Tayade .

    modified on Tuesday, May 24, 2011 6:32 AM

    L M P 3 Replies Last reply
    0
    • U User 4547220

      Hi, I have a following file names in my database. TestDocument _ 1 _ 0 TestDocument _ Evidence Test45 123_publish when i am entering the Test_ in the DocumentName textbox it is forst converted to uppercase and send to the query and query has following expression which returns all record where it should not have to return any record. please tell me the changes in the following expression. UPPER(DOC.ORIGINAL_FILE_NAME) like '%TEST_%' Thanks, Umesh Tayade .

      modified on Tuesday, May 24, 2011 6:32 AM

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      This looks like a database question, not a C# issue. And wildcard operations aren't the same for all databases, so you'll have to specify what it is you are using. :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      U 1 Reply Last reply
      0
      • U User 4547220

        Hi, I have a following file names in my database. TestDocument _ 1 _ 0 TestDocument _ Evidence Test45 123_publish when i am entering the Test_ in the DocumentName textbox it is forst converted to uppercase and send to the query and query has following expression which returns all record where it should not have to return any record. please tell me the changes in the following expression. UPPER(DOC.ORIGINAL_FILE_NAME) like '%TEST_%' Thanks, Umesh Tayade .

        modified on Tuesday, May 24, 2011 6:32 AM

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Seriously, you can't see the issue. Take a look at your file names and point out the name that starts with 'TEST_'. I see TestDocument and Test45 no Test_

        Never underestimate the power of human stupidity RAH

        U 1 Reply Last reply
        0
        • U User 4547220

          Hi, I have a following file names in my database. TestDocument _ 1 _ 0 TestDocument _ Evidence Test45 123_publish when i am entering the Test_ in the DocumentName textbox it is forst converted to uppercase and send to the query and query has following expression which returns all record where it should not have to return any record. please tell me the changes in the following expression. UPPER(DOC.ORIGINAL_FILE_NAME) like '%TEST_%' Thanks, Umesh Tayade .

          modified on Tuesday, May 24, 2011 6:32 AM

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Are you aware that, in Sql Server at least, the underscore character (_) is the wildcard for a single character? Very nasty in my opinion. You may wish to specify a different character in your query.

          1 Reply Last reply
          0
          • M Mycroft Holmes

            Seriously, you can't see the issue. Take a look at your file names and point out the name that starts with 'TEST_'. I see TestDocument and Test45 no Test_

            Never underestimate the power of human stupidity RAH

            U Offline
            U Offline
            User 4547220
            wrote on last edited by
            #5

            Hi, I know that there is no document with the name TEST in my database but what i am telling is that when i search for TEST_ it should not have to return any records. but it is returning the records. Thanks, Umesh Tayade Never Underestimate the power of Human Stupidity

            P 2 Replies Last reply
            0
            • L Luc Pattyn

              This looks like a database question, not a C# issue. And wildcard operations aren't the same for all databases, so you'll have to specify what it is you are using. :)

              Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

              U Offline
              U Offline
              User 4547220
              wrote on last edited by
              #6

              Hi, I am using Oracle10g database. Thanks, Umesh Tayade

              L 1 Reply Last reply
              0
              • U User 4547220

                Hi, I know that there is no document with the name TEST in my database but what i am telling is that when i search for TEST_ it should not have to return any records. but it is returning the records. Thanks, Umesh Tayade Never Underestimate the power of Human Stupidity

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

                It is returning records because you have two sets of wildcards in the query. In other words, you have the % and the _ characters. Effectively, your query is %TEST%.

                Forgive your enemies - it messes with their heads

                My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                1 Reply Last reply
                0
                • U User 4547220

                  Hi, I know that there is no document with the name TEST in my database but what i am telling is that when i search for TEST_ it should not have to return any records. but it is returning the records. Thanks, Umesh Tayade Never Underestimate the power of Human Stupidity

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

                  If you want to use the _ as a valid identifier in your query rather than having it act as a wildcard, you should precede it with a \, so your query would become %TEST\_%.

                  Forgive your enemies - it messes with their heads

                  My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                  1 Reply Last reply
                  0
                  • U User 4547220

                    Hi, I am using Oracle10g database. Thanks, Umesh Tayade

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #9

                    Oracle wi_dcards[^]. :)

                    Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                    Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                    modified on Tuesday, May 24, 2011 7:21 AM

                    P 1 Reply Last reply
                    0
                    • L Luc Pattyn

                      Oracle wi_dcards[^]. :)

                      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                      modified on Tuesday, May 24, 2011 7:21 AM

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

                      Windcards? Where did the OP mention chronic flatulence?

                      Forgive your enemies - it messes with their heads

                      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                      L 1 Reply Last reply
                      0
                      • P Pete OHanlon

                        Windcards? Where did the OP mention chronic flatulence?

                        Forgive your enemies - it messes with their heads

                        My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                        L Offline
                        L Offline
                        Luc Pattyn
                        wrote on last edited by
                        #11

                        Sorry. I meant windcharts of course. Fixed it. Thanks. :)

                        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                        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