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. No rows returned using SQLiteParameters, but rows returned with direct query

No rows returned using SQLiteParameters, but rows returned with direct query

Scheduled Pinned Locked Moved Database
databasesqlitecomdebugginghelp
13 Posts 3 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 Uranium 235

    tried and failed. wait, using it without ' in the query string works. yes, thank you though I can still input % as a wildcard and get all rows. I thought this supposed to sanitize/escape input. guess I can live with it though, unless you have a better idea

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #4

    Yes, because parameter names must be entered 'as is', not quoted.

    U 1 Reply Last reply
    0
    • L Lost User

      Yes, because parameter names must be entered 'as is', not quoted.

      U Offline
      U Offline
      Uranium 235
      wrote on last edited by
      #5

      do you know why the % char isnt being escaped?

      L 1 Reply Last reply
      0
      • U Uranium 235

        do you know why the % char isnt being escaped?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #6

        Not sure what you mean, I thought is was the wildcard character for the LIKE phrase.

        U 1 Reply Last reply
        0
        • L Lost User

          Not sure what you mean, I thought is was the wildcard character for the LIKE phrase.

          U Offline
          U Offline
          Uranium 235
          wrote on last edited by
          #7

          yes, but if it's put into the textbox, it's queried as LIKE %%% which matches everything

          L 1 Reply Last reply
          0
          • U Uranium 235

            yes, but if it's put into the textbox, it's queried as LIKE %%% which matches everything

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #8

            I'm sorry, you have lost me. What has a TextBox got to do with SQL statements?

            U 1 Reply Last reply
            0
            • L Lost User

              I'm sorry, you have lost me. What has a TextBox got to do with SQL statements?

              U Offline
              U Offline
              Uranium 235
              wrote on last edited by
              #9

              it's a search query for a database, text input box

              L 1 Reply Last reply
              0
              • U Uranium 235

                it's a search query for a database, text input box

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #10

                Yes, but that has nothing to do with creating a valid SQL statement. The textbox is provided by the user, so your code should verify that it contains valid data. You then take the validated text and store into one of the SQL Parameters which get passed in to he execution module. Do not assume that the user knows what he or she is doing and just accept whatever they type. Many times it will be wrong, mist-typed, not understanding what is required, etc.

                U 1 Reply Last reply
                0
                • L Lost User

                  Yes, but that has nothing to do with creating a valid SQL statement. The textbox is provided by the user, so your code should verify that it contains valid data. You then take the validated text and store into one of the SQL Parameters which get passed in to he execution module. Do not assume that the user knows what he or she is doing and just accept whatever they type. Many times it will be wrong, mist-typed, not understanding what is required, etc.

                  U Offline
                  U Offline
                  Uranium 235
                  wrote on last edited by
                  #11

                  I thought SQLLiteParameter sanitizes or at least escapes special characters

                  L R 2 Replies Last reply
                  0
                  • U Uranium 235

                    I thought SQLLiteParameter sanitizes or at least escapes special characters

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #12

                    Sorry, I don't know, you would need to check the documentation.

                    1 Reply Last reply
                    0
                    • U Uranium 235

                      I thought SQLLiteParameter sanitizes or at least escapes special characters

                      R Offline
                      R Offline
                      Richard Deeming
                      wrote on last edited by
                      #13

                      Parameters don't "sanitize" or "escape" special characters. They pass parameters across completely separately from the command text, so that there is no way for the database engine to get confused and treat part of the parameter as part of the command. Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^] How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]


                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                      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