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. Why is this a syntax error?

Why is this a syntax error?

Scheduled Pinned Locked Moved Database
helpquestion
4 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.
  • M Offline
    M Offline
    MikeMarq
    wrote on last edited by
    #1

    When I run this code I get this error message "Syntax error in INSERT INTO statement". Can anyone explain why my command is a syntax error? Thanks. rsGuest.Open("Guest", ADOConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Dim command As String command = "INSERT INTO Guest(Guest ID) VALUES('1111')" ADOConnection.Execute(command, rsGuest)

    A K 2 Replies Last reply
    0
    • M MikeMarq

      When I run this code I get this error message "Syntax error in INSERT INTO statement". Can anyone explain why my command is a syntax error? Thanks. rsGuest.Open("Guest", ADOConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Dim command As String command = "INSERT INTO Guest(Guest ID) VALUES('1111')" ADOConnection.Execute(command, rsGuest)

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      There are two possible reasons I can see. Firstly, your syntax is wrong: command = "INSERT INTO Guest(Guest ID) VALUES('1111')" Should be command = "INSERT INTO Guest**[**Guest ID**]** VALUES('1111')" Also, is [Guest ID] an identity (autonumber) column?

      Bob Ashfield Consultants Ltd

      1 Reply Last reply
      0
      • M MikeMarq

        When I run this code I get this error message "Syntax error in INSERT INTO statement". Can anyone explain why my command is a syntax error? Thanks. rsGuest.Open("Guest", ADOConnection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Dim command As String command = "INSERT INTO Guest(Guest ID) VALUES('1111')" ADOConnection.Execute(command, rsGuest)

        K Offline
        K Offline
        Krish KP
        wrote on last edited by
        #3

        column name Guest ID is having space so it cannot be used directly use it like this command = "INSERT INTO Guest([Guest ID]) VALUES('1111')"

        Regards KP

        A 1 Reply Last reply
        0
        • K Krish KP

          column name Guest ID is having space so it cannot be used directly use it like this command = "INSERT INTO Guest([Guest ID]) VALUES('1111')"

          Regards KP

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          Sorry, thats what I meant - you need to put Guest ID in square brackets, I didn't mean to lose the () round it. Old age and failing eyesight to blame ;)

          Bob Ashfield Consultants Ltd

          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