Skip to main content
Participant
June 26, 2008
Question

Syntax eror in INSERT INTO satement

  • June 26, 2008
  • 3 replies
  • 391 views
I get this when i try to insert information in the database:

[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

thanks for the help in advanced
This topic has been closed for replies.

3 replies

Epid3mikAuthor
Participant
June 26, 2008
thanks for the help I figured that out
Inspiring
June 26, 2008
Epid3mik
> I get this when i try to insert information in the database:

I suspect some of your column names are reserved keywords, such as FROM, TIME, etcetera.
http://support.microsoft.com/kb/286335

Whenever possible, avoid using keywords as object names. The better solution here is to permanently rename the columns that are keywords. Assuming the rest of your query syntax is correct, that should fix the syntax error. If for some reason you cannot rename the columns, you must escape them by using square brackets around the column names:

INSERT INTO Message ( mem_id, [From], [Time], .... )

As an aside, you should properly scope your variables. Example use #FORM.mem_id# instead of just #mem_id#. Your should also consider using cfqueryparam for all query values. These last two things are not the cause of your error, but they are good coding practices.


Inspiring
June 26, 2008
first off do the insert in the same order as the form so start with message_content then men_id etc.

Take out the submit and the reset and put them at the end of the code-you are presently not send the form before you have all the data. Get cracking on those things, when you have sorted them out then use comments or just do one field at a time to check if it works when you insert the data (stat with message_content see if it works when you submit your new form if it does then add the men_id field then the next one etc. and you will see where andif an error occurs)

Good luck coldfusion rocks