Click to See Complete Forum and Search --> : INSERT help


jrthor2
07-11-2003, 08:50 AM
Can anyone tell me why I am getting this error:

Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement

With this insert statement:

SQLstmt = "INSERT INTO News (BEGIN_DTE, END_DTE, CATEGORY, SUBJECT, SUB_HEADING1, SUB_HEADING2, IMAGE, TEXT, LST_OPR_ID)"
SQLstmt = SQLstmt & " VALUES ("
SQLstmt = SQLstmt & DATE_DELIMITER & strbegindate & DATE_DELIMITER
SQLstmt = SQLstmt & ", "
SQLstmt = SQLstmt & DATE_DELIMITER & strenddate & DATE_DELIMITER
SQLstmt = SQLstmt & ", "
SQLstmt = SQLstmt & "'" & strcategory & "', "
SQLstmt = SQLstmt & "'" & strsubject & "', "
SQLstmt = SQLstmt & "'" & strsubheading1 & "', "
SQLstmt = SQLstmt & "'" & strsubheading2 & "', "
SQLstmt = SQLstmt & "'" & strimage & "', "
SQLstmt = SQLstmt & "'" & strtext & "', "
SQLstmt = SQLstmt & "'" & strusername & "'"
SQLstmt = SQLstmt & ");"

jrthor2
07-11-2003, 09:27 AM
Not sure why this works, but I had to put [] around the IMAGE column like this:

SQLstmt = "INSERT INTO News (BEGIN_DTE, END_DTE, CATEGORY, SUBJECT, SUB_HEADING1, SUB_HEADING2, [IMAGE], NEWS_TXT, LST_OPR_ID)"

rtatnell
07-11-2003, 09:28 AM
I'm reasonably new to all this, but I had some trouble a while back with my insert into statements, where I was using a field called Date in my records. Some words are reserved words and cause a problem if used in an INSERT statement. Try putting some of the words in your first bracket set inside square brackets. I think you might be having a problem with your fields named Text, Image, and possibly some others. Try something like:

SQLstmt = "INSERT INTO News (BEGIN_DTE, END_DTE, CATEGORY, SUBJECT, SUB_HEADING1, SUB_HEADING2, [IMAGE], [TEXT], LST_OPR_ID)"

Probs wont help, but you never know!

rtatnell
07-11-2003, 09:29 AM
Oops, im a bit late, u've kinda got an answer there to ur second question in my previous post anyway!