error on sql insert

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashwika42
    New Member
    • Sep 2013
    • 5

    error on sql insert

    hi
    I am getting an error :
    on execute statement ! :

    error is :

    Microsoft OLE DB Provider for SQL Server error '80040e14'
    Incorrect syntax near ','.

    --------------------------------
    this is the statement :

    Code:
    sql = "insert into requirements (message, priority,server, ip, usr, creationTime, modificationTime, Title, deleted, " &_
    "EventName, PriorityComm, Service, CallRef, Description, DateTimeIncident, BusinessImpact, NextSteps) values " &_
    "('" & strData & "', " & priority & ", '" & ip & "', '" & usr & "', GetDate(), GetDate(),'" & title & "','" & eventName & "') " &_ 
    "('" & priorityComm & "','" & service & "','" & callRef & "','" & description & "', GetDateTime(),'" & businessImpact & "','" & nextSteps & "') "
    
    
    DbObj.Execute(SQL)
    on error resume next


    any help would be much appreciated .


    Thanks
    Last edited by Rabbit; Oct 16 '13, 03:20 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    On initial inpection I think you need to change this
    , GetDate(), GetDate(),
    to this
    ," & GetDate() & ", " & GetDate() & ",

    and this
    , GetDateTime(),
    to
    ," & GetDateTime() & ",

    Or possibly even this
    ,#" & Format(GetDate( ),"mm/dd/yyyy") & "#, #" & Format(GetDate( ),"mm/dd/yyyy") & "#,
    and
    ,#" & Format(GetDateT ime(),"mm/dd/yyyy") & "#,

    ??

    HTH

    Comment

    • ashwika42
      New Member
      • Sep 2013
      • 5

      #3
      sorry my mistake I have too many fields on the insert : it should be :
      Code:
      sql = "insert into requirements(message, priority, ip, usr, creationTime, modificationTime, Title,  " &_
            "EventName, PriorityComm, Service, CallRef, Description,  DateTimeIncident, BusinessImpact, NextSteps) values " &_
           "('" & strData & "', " & priority & ",'" & ip & "', '" & usr & "', GetDate(), GetDate(),'" & title & "','" & eventName & "',)" &_ 
          "('" & priorityComm & "','" & service & "','" & callRef & "','" & description & "', GetDateTime(),'" & businessImpact & "','" & nextSteps & "') "     
      
      I am still getting the error - could it be from 
      DbObj.Execute(SQL)
       on error resume next
      I will take your advise ... and see ....
      Last edited by Rabbit; Oct 16 '13, 03:22 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.

      Comment

      • ashwika42
        New Member
        • Sep 2013
        • 5

        #4
        I tried replacing with " & GetDate() &" etc but still sam error

        Comment

        • MikeTheBike
          Recognized Expert Contributor
          • Jun 2007
          • 640

          #5
          You have nit tried my suggestions?

          Comment

          • ashwika42
            New Member
            • Sep 2013
            • 5

            #6
            I tried that too - I got the error
            Type mismatch: 'GetDate'

            Comment

            • MikeTheBike
              Recognized Expert Contributor
              • Jun 2007
              • 640

              #7
              What does GetDate() return?

              is it a date or a string?

              I suggest you either insert msgbox SQL or debug.print sql before DbObj.Execute(S QL) and examine the resulting string and post it here if you use the debug.print optuon (the string will appear in the immediate window - Ctrl+G).

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                Please use code tags when posting code or formatted data.

                You have extra parentheses at the end of line 3 and the beginning of line 4.

                Comment

                Working...