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. Syntax error (missing operator) in query expression

Syntax error (missing operator) in query expression

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

    updatecom.CommandText="update test2 set name='" + textBox1.Text + "' job= '" + textBox2.Text +"' title='" + textBox3.Text + "'where id=" + textBox4.Text + "";

    Ahmed hassan

    P W C L 4 Replies Last reply
    0
    • H hassanasp

      updatecom.CommandText="update test2 set name='" + textBox1.Text + "' job= '" + textBox2.Text +"' title='" + textBox3.Text + "'where id=" + textBox4.Text + "";

      Ahmed hassan

      P Offline
      P Offline
      PH MAT
      wrote on last edited by
      #2

      try some comma's between the ' and job and ' and title

      H 1 Reply Last reply
      0
      • P PH MAT

        try some comma's between the ' and job and ' and title

        H Offline
        H Offline
        hassanasp
        wrote on last edited by
        #3

        not working

        Ahmed hassan

        1 Reply Last reply
        0
        • H hassanasp

          updatecom.CommandText="update test2 set name='" + textBox1.Text + "' job= '" + textBox2.Text +"' title='" + textBox3.Text + "'where id=" + textBox4.Text + "";

          Ahmed hassan

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #4

          And as an addition to the previous post, use parameters for values. You are now for example vulnerable to sql injections.

          The need to optimize rises from a bad design.My articles[^]

          1 Reply Last reply
          0
          • H hassanasp

            updatecom.CommandText="update test2 set name='" + textBox1.Text + "' job= '" + textBox2.Text +"' title='" + textBox3.Text + "'where id=" + textBox4.Text + "";

            Ahmed hassan

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

            1: instead of saying 'not working', tell us what the error is. Putting commas in to fix your SQL will obviously work. 2: read up on SQL Injection attacks, to find out how I can erase your entire database if you release this code 3: tell me you're not really using variables called textBox1, textBox2, etc. Or are you trying to write unreadable code on purpose ?

            Christian Graus Driven to the arms of OSX by Vista.

            1 Reply Last reply
            0
            • H hassanasp

              updatecom.CommandText="update test2 set name='" + textBox1.Text + "' job= '" + textBox2.Text +"' title='" + textBox3.Text + "'where id=" + textBox4.Text + "";

              Ahmed hassan

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

              You may try this: updatecom.CommandText = "update test2 set name='" + textBox1.Text + "', job= '" + textBox2.Text +"', title='" + textBox3.Text + "' where id='" + textBox4.Text + "'"; Fixed "," and "'"

              Saludos!! ____Juan

              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