when iam trying to add data to the database i get this error

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

here is the add.sign.asp

<!--#include file="connection.asp" -->

	<%
		adddate=now()
		name=request.form("name")
		email=request.form("email")
		ranking=request.form("ranking")
		notes=request.form("notes")
		
		if name="" or ranking="" or notes="" then
		response.write"الرجاء ادخال جميع الحقول المطلوبة"
		else
		addSQL="insert into guestbook (date,name,email,ranking,content) values('"&adddate&"','"&name&"','"&email&"','"&ranking&"','"&notes&"') " 
   		SB.execute(addSQL)
   		response.redirect "guest.book.asp"
   		End if

		SB.close
		Set SB=Nothing
	%>

is there something wrong in this code .. ??

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.

<%
		adddate=now()
		name=request.form("name")
		email=request.form("email")
		ranking=request.form("ranking")
		notes=request.form("notes")
		
		if name="" or ranking="" or notes="" then
		response.write"الرجاء ادخال جميع الحقول المطلوبة"
		else
		addSQL="insert into guestbook (date) values('"&adddate&"') " 
   		SB.execute(addSQL)
   		response.redirect "guest.book.asp"
   		End if

		SB.close
		Set SB=Nothing
	%>

Try this:

<!--#include file="connection.asp" -->

	<%
		adddate=now()
		name=request.form("name")
		email=request.form("email")
		ranking=request.form("ranking")
		notes=request.form("notes")
		
		if name="" or ranking="" or notes="" then
		response.write"الرجاء ادخال جميع الحقول المطلوبة"
		else
		addSQL="insert into [guestbook] ([date],[name],[email],[ranking],[content]) values('"&adddate&"','"&name&"','"&email&"','"&ranking&"','"&notes&"') " 
   		SB.execute(addSQL)
   		response.redirect "guest.book.asp"
   		End if

		SB.close
		Set SB=Nothing
	%>

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.

i get this error " Operation must use an updateable query " :(

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.

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:

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

This article has been dead for over six months. Start a new discussion instead.