Syntax error in INSERT INTO statement, please help

Reply

Join Date: Feb 2008
Posts: 6
Reputation: SBox is an unknown quantity at this point 
Solved Threads: 0
SBox SBox is offline Offline
Newbie Poster

Syntax error in INSERT INTO statement, please help

 
0
  #1
Feb 19th, 2008
when iam trying to add data to the database i get this error

  1. Microsoft JET Database Engine (0x80040E14)
  2. Syntax error in INSERT INTO statement.
  3. /science/add.sign.asp, line 14

here is the add.sign.asp

  1. <!--#include file="connection.asp" -->
  2.  
  3. <%
  4. adddate=now()
  5. name=request.form("name")
  6. email=request.form("email")
  7. ranking=request.form("ranking")
  8. notes=request.form("notes")
  9.  
  10. if name="" or ranking="" or notes="" then
  11. response.write"الرجاء ادخال جميع الحقول المطلوبة"
  12. else
  13. addSQL="insert into guestbook (date,name,email,ranking,content) values('"&adddate&"','"&name&"','"&email&"','"&ranking&"','"&notes&"') "
  14. SB.execute(addSQL)
  15. response.redirect "guest.book.asp"
  16. End if
  17.  
  18. SB.close
  19. Set SB=Nothing
  20. %>
is there something wrong in this code .. ??
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 174
Reputation: TobbeK is an unknown quantity at this point 
Solved Threads: 3
TobbeK TobbeK is offline Offline
Junior Poster

Re: Syntax error in INSERT INTO statement, please help

 
0
  #2
Feb 20th, 2008
Try to limit the inserted fields in testing, and then add the other fields one by one to you see which of the them failed. I can't see any wrong with your code, I wild guess is that the date format in the database doesn't accept the date input. If the other fields been inserted then you know.

  1. <%
  2. adddate=now()
  3. name=request.form("name")
  4. email=request.form("email")
  5. ranking=request.form("ranking")
  6. notes=request.form("notes")
  7.  
  8. if name="" or ranking="" or notes="" then
  9. response.write"الرجاء ادخال جميع الحقول المطلوبة"
  10. else
  11. addSQL="insert into guestbook (date) values('"&adddate&"') "
  12. SB.execute(addSQL)
  13. response.redirect "guest.book.asp"
  14. End if
  15.  
  16. SB.close
  17. Set SB=Nothing
  18. %>
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Syntax error in INSERT INTO statement, please help

 
0
  #3
Feb 21st, 2008
Try this:
  1. <!--#include file="connection.asp" -->
  2.  
  3. <%
  4. adddate=now()
  5. name=request.form("name")
  6. email=request.form("email")
  7. ranking=request.form("ranking")
  8. notes=request.form("notes")
  9.  
  10. if name="" or ranking="" or notes="" then
  11. response.write"الرجاء ادخال جميع الحقول المطلوبة"
  12. else
  13. addSQL="insert into [guestbook] ([date],[name],[email],[ranking],[content]) values('"&adddate&"','"&name&"','"&email&"','"&ranking&"','"&notes&"') "
  14. SB.execute(addSQL)
  15. response.redirect "guest.book.asp"
  16. End if
  17.  
  18. SB.close
  19. Set SB=Nothing
  20. %>
Also check to make sure that date isn't a reserved keyword, because I believe it is. Change date to datecreated and update the sql statement.

Also check to see if rankings data type. If your column in your msaccess database is integer, you need to remove the SINGLE quotes around rankings in the sql statement. Integers cannot be surrounded by single quotes, otherwise it's considered as a string and will not insert.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 6
Reputation: SBox is an unknown quantity at this point 
Solved Threads: 0
SBox SBox is offline Offline
Newbie Poster

Re: Syntax error in INSERT INTO statement, please help

 
0
  #4
Feb 21st, 2008
i get this error " Operation must use an updateable query "
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Syntax error in INSERT INTO statement, please help

 
0
  #5
Feb 21st, 2008
well I have never heard that one before.

But it is due to permissions. Make sure you have permissions to the folder your database is stored, and also make sure the mdb file isn't write protected or read-only. Then check to make sure your columns aren't bound to other tables, like foreign keys. Basically, make sure you can write to the file mdb, and make sure your columns can be updated.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 174
Reputation: TobbeK is an unknown quantity at this point 
Solved Threads: 3
TobbeK TobbeK is offline Offline
Junior Poster

Re: Syntax error in INSERT INTO statement, please help

 
0
  #6
Feb 21st, 2008
Most possible a permission setting. I have seen that before.
Last edited by TobbeK; Feb 21st, 2008 at 3:09 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 4
Reputation: krowden is an unknown quantity at this point 
Solved Threads: 0
krowden krowden is offline Offline
Newbie Poster

Re: Syntax error in INSERT INTO statement, please help

 
0
  #7
Feb 26th, 2008
Two things:

1. the 'date'column is a reserved word so use the '[date]' syntax as previously mentioned - or a better solution is NOT to use reserved words! ;^)

Sorry, forgot: you should also use the # sign around a date (instead of the single quote), thus:

  1. insert into mytable (mynumbercol, mytextcol, mydatecol) values (123, 'some text string', #26-feb-2008#)

2. The 'must use an updateble query' msg IS a permissions issue for the IIS webuser:
- Go to your .MDB file, right-click and then click 'properties'.
- Click on the 'security' tab
- select the IIS user (will typically have 'IUSR' in the name, but may be something else)
- click all check boxes under the 'allow' column
- save and exit.

Try your script again.

-Kim
Last edited by krowden; Feb 26th, 2008 at 2:04 pm. Reason: forgot insert statement
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC