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. Web Development
  3. INSERT INTO/ASP/ADO- error

INSERT INTO/ASP/ADO- error

Scheduled Pinned Locked Moved Web Development
databasehelpcomsysadminquestion
5 Posts 3 Posters 1 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.
  • J Offline
    J Offline
    Jarmo
    wrote on last edited by
    #1

    Can anybody help me? The very simple below code doesnt work. It returns a following error: "Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. "MYDATABASE" is a access database. And "number" is a integer. THANK YOU, JARMO The code: <% dim objConn dim objTimes dim strQuery Set objConn = Server.Createobject("ADODB.Connection") Set objTimes = Server.Createobject("ADODB.Recordset") objConn.Open "MYDATABASE" strQuery="INSERT INTO Contacts (Number) VALUES (15)" set objTimes = objConn.Execute (strQuery)%>

    J 1 Reply Last reply
    0
    • J Jarmo

      Can anybody help me? The very simple below code doesnt work. It returns a following error: "Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. "MYDATABASE" is a access database. And "number" is a integer. THANK YOU, JARMO The code: <% dim objConn dim objTimes dim strQuery Set objConn = Server.Createobject("ADODB.Connection") Set objTimes = Server.Createobject("ADODB.Recordset") objConn.Open "MYDATABASE" strQuery="INSERT INTO Contacts (Number) VALUES (15)" set objTimes = objConn.Execute (strQuery)%>

      J Offline
      J Offline
      Jarmo
      wrote on last edited by
      #2

      The Code, which dropped: dim objConn dim objTimes dim strQuery Set objConn = Server.Createobject("ADODB.Connection") Set objTimes = Server.Createobject("ADODB.Recordset") objConn.Open "HIERONTA" strQuery="INSERT INTO Contacts (Number) VALUES ('15')" set objTimes = objConn.Execute (strQuery)

      L T 3 Replies Last reply
      0
      • J Jarmo

        The Code, which dropped: dim objConn dim objTimes dim strQuery Set objConn = Server.Createobject("ADODB.Connection") Set objTimes = Server.Createobject("ADODB.Recordset") objConn.Open "HIERONTA" strQuery="INSERT INTO Contacts (Number) VALUES ('15')" set objTimes = objConn.Execute (strQuery)

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

        Well, first off, you don't need to create a recordset when all you are doing is INSERTing records into the database. To execute the SQL string, all you have to do is put

        objConn.Execute (strQuery)

        . Secondly, your SQL string should be stated like this:

        strQuery = "INSERT INTO Contacts ('" & Number & "') VALUES ('15')"

        I am assuming that Number is a variable you are passing into it. If it is just a number and not a variable, then the way you have it is fine. However, judging from the error message you posted, the former reason is the case (passing a variable using the wrong syntax). Lastly, you can remove the dim objTimes declaration and the Set objTimes = CreateObject("ADODB.Recordset") line. Again, all of this assuming all you are doing is INSERTing records. If you are retrieving records then you just need to change the SQL string. Try these and see what happens. If they do or if they don't, feel free to shoot me an email letting me know. Hope it helps, Tobey Unruh ================== The original message was: The Code, which dropped:

        dim objConn
        dim objTimes
        dim strQuery

        Set objConn = Server.Createobject("ADODB.Connection")
        Set objTimes = Server.Createobject("ADODB.Recordset")
        objConn.Open "HIERONTA"
        strQuery="INSERT INTO Contacts (Number) VALUES ('15')"
        set objTimes = objConn.Execute (strQuery)

        1 Reply Last reply
        0
        • J Jarmo

          The Code, which dropped: dim objConn dim objTimes dim strQuery Set objConn = Server.Createobject("ADODB.Connection") Set objTimes = Server.Createobject("ADODB.Recordset") objConn.Open "HIERONTA" strQuery="INSERT INTO Contacts (Number) VALUES ('15')" set objTimes = objConn.Execute (strQuery)

          T Offline
          T Offline
          Tom Wellige
          wrote on last edited by
          #4

          > strQuery="INSERT INTO Contacts (Number) VALUES ('15')" The error message says that you are trying to pass a string value into an integer field. Try this: strQuery="INSERT INTO Contacts (Number) VALUES (15)" Regards, Tom.

          1 Reply Last reply
          0
          • J Jarmo

            The Code, which dropped: dim objConn dim objTimes dim strQuery Set objConn = Server.Createobject("ADODB.Connection") Set objTimes = Server.Createobject("ADODB.Recordset") objConn.Open "HIERONTA" strQuery="INSERT INTO Contacts (Number) VALUES ('15')" set objTimes = objConn.Execute (strQuery)

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

            There is a field size in your DB that is too small to accept the data. Check your field sizes.

            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