Skip to main content
July 26, 2010
Answered

old code stops inserting to a database

  • July 26, 2010
  • 1 reply
  • 736 views

I have a few lines of very simple code that have stopped working after the server was upgraded to new Microsoft server.  The database is Access 2010.

The  error code is 500 and that the syntax is not good.  I have tried changing to the alternate <cfinsert> option but that still does not work.  I have also tried putting the  variables inside primes (' #xxx# ')

<cfquery datasource="pcrsp" name="Addrecord">       
            INSERT INTO ANNPLANREP (objectiveID, ProjectID, Year)
            VALUES (#objectiveID#, #ProjectID#, #Year#)
</cfquery>

The code has worked without issue for years what is happening?  Other code working with this table successfuly updates the records.

Any ideas?

Tim

    This topic has been closed for replies.
    Correct answer -__cfSearching__-

    Another possibility is "Year" may be a reserved keyword. In which case it must be escaped when used as an object name. To escape the column name, add square brackets around it ie  [Year] .  Though using reserved keywords as object names is generally not recommended. So if this is indeed the problem, you might consider renaming the column instead.

    Message was edited by: -==cfSearching==-

    1 reply

    Inspiring
    July 26, 2010

    Sounds like a driver problem.

    -__cfSearching__-Correct answer
    Inspiring
    July 27, 2010

    Another possibility is "Year" may be a reserved keyword. In which case it must be escaped when used as an object name. To escape the column name, add square brackets around it ie  [Year] .  Though using reserved keywords as object names is generally not recommended. So if this is indeed the problem, you might consider renaming the column instead.

    Message was edited by: -==cfSearching==-

    July 27, 2010

    The answer was in the restricted.  Thankyou

    words - presumeably 10 years ago that was not a restricted word.  Seems to me that a useful utility would be the ability to scan old code for changes inthe restrictions with newer versions of coldfusion, alternatively to have the error codes specifically identify that this was a restricted word.