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. How to use textbox value in sql statement

How to use textbox value in sql statement

Scheduled Pinned Locked Moved C#
databasehelptutorialquestion
6 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.
  • Z Offline
    Z Offline
    zenithmaximus
    wrote on last edited by
    #1

    Hi all, here's a part of the code im tryin to use "WHERE PSCustID LIKE '"+ txtSearchString.Text +"%'"; and i got error when running it... am i doin it right? tnx in advance ;) -::maximus::-

    D S 2 Replies Last reply
    0
    • Z zenithmaximus

      Hi all, here's a part of the code im tryin to use "WHERE PSCustID LIKE '"+ txtSearchString.Text +"%'"; and i got error when running it... am i doin it right? tnx in advance ;) -::maximus::-

      D Offline
      D Offline
      DIMPLE_R
      wrote on last edited by
      #2

      What's the error that you are getting? -- modified at 2:52 Thursday 6th July, 2006

      Z 1 Reply Last reply
      0
      • D DIMPLE_R

        What's the error that you are getting? -- modified at 2:52 Thursday 6th July, 2006

        Z Offline
        Z Offline
        zenithmaximus
        wrote on last edited by
        #3

        An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll -::maximus::-

        D 1 Reply Last reply
        0
        • Z zenithmaximus

          An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll -::maximus::-

          D Offline
          D Offline
          DIMPLE_R
          wrote on last edited by
          #4

          Hi.. The part of the SQL statement that you've sent seems correct...You need to get a specific error to understand what exactly is going wrong.. You can do one thing, use Try-Catch to handle the exception. Try //code Catch ex as OleDbException' MessageBox.Show(ex.Message) End Try

          Z 1 Reply Last reply
          0
          • Z zenithmaximus

            Hi all, here's a part of the code im tryin to use "WHERE PSCustID LIKE '"+ txtSearchString.Text +"%'"; and i got error when running it... am i doin it right? tnx in advance ;) -::maximus::-

            S Offline
            S Offline
            Stefan Troschuetz
            wrote on last edited by
            #5

            You should use parameterized qzeries to increase security of your code as well as readibility. Take a look at the following article here on CP: SQL Injection Attacks and Some Tips on How to Prevent Them[^]


            "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

            www.troschuetz.de

            1 Reply Last reply
            0
            • D DIMPLE_R

              Hi.. The part of the SQL statement that you've sent seems correct...You need to get a specific error to understand what exactly is going wrong.. You can do one thing, use Try-Catch to handle the exception. Try //code Catch ex as OleDbException' MessageBox.Show(ex.Message) End Try

              Z Offline
              Z Offline
              zenithmaximus
              wrote on last edited by
              #6

              ok tnx, ill try it. -::maximus::-

              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