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. Visual Basic
  4. Syntaxiserror in updatecommand

Syntaxiserror in updatecommand

Scheduled Pinned Locked Moved Visual Basic
databaseagentic-aihelpannouncement
2 Posts 2 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.
  • K Offline
    K Offline
    keninfo
    wrote on last edited by
    #1

    Why is it that when i use the updatecommand als below, i get the error: Syntaxiserror (operator missing) in query-expression daAgent.UpdateCommand.CommandText = ("Update Agent" & _ " SET Nummer_Naam = " & agentNummerNaam & _ ", Agentnummer = " & txtAgentNummer.Text & _ ", Agentnaam = " & txtAgentNaam.Text & _ " WHERE(Agentnummer = " & agentNummerOud & ")") daAgent.UpdateCommand.Connection.Open() daAgent.UpdateCommand.ExecuteReader() daAgent.UpdateCommand.Connection.Close()

    C 1 Reply Last reply
    0
    • K keninfo

      Why is it that when i use the updatecommand als below, i get the error: Syntaxiserror (operator missing) in query-expression daAgent.UpdateCommand.CommandText = ("Update Agent" & _ " SET Nummer_Naam = " & agentNummerNaam & _ ", Agentnummer = " & txtAgentNummer.Text & _ ", Agentnaam = " & txtAgentNaam.Text & _ " WHERE(Agentnummer = " & agentNummerOud & ")") daAgent.UpdateCommand.Connection.Open() daAgent.UpdateCommand.ExecuteReader() daAgent.UpdateCommand.Connection.Close()

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

      Your code is susceptable to SQL Injection Attack. Please read SQL Injection Attacks and Tips on How to Prevent Them[^]. You use ExecuteReader. But you don't get any information back. You should ExecuteNonQuery() when you don't expect a result set. You are allowing unvalidated and unsanitised user input directly into the SQL Statement. It is highly possible that this dirty information is causing problems for your SQL Statement. The advice given in SQL Injection Attacks and Tips on How to Prevent Them[^] will help you generate a safe SQL command that will be protected against that sort of error when caused by user input.


      Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

      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