| | |
Syntax error in INSERT INTO statement, please help
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2008
Posts: 6
Reputation:
Solved Threads: 0
when iam trying to add data to the database i get this error
here is the add.sign.asp
is there something wrong in this code .. ??
ASP Syntax (Toggle Plain Text)
Microsoft JET Database Engine (0x80040E14) Syntax error in INSERT INTO statement. /science/add.sign.asp, line 14
here is the add.sign.asp
ASP Syntax (Toggle Plain Text)
<!--#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&"','"¬es&"') " SB.execute(addSQL) response.redirect "guest.book.asp" End if SB.close Set SB=Nothing %>
•
•
Join Date: Feb 2008
Posts: 174
Reputation:
Solved Threads: 3
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.
ASP Syntax (Toggle Plain Text)
<% 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 %>
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
Try this:
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.
ASP Syntax (Toggle Plain Text)
<!--#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&"','"¬es&"') " SB.execute(addSQL) response.redirect "guest.book.asp" End if SB.close Set SB=Nothing %>
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.
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
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.
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.
•
•
Join Date: Feb 2008
Posts: 4
Reputation:
Solved Threads: 0
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:
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
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:
ASP Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- Shopping Cart Not Working (ASP.NET)
- problem with quotes in SQL statement (Visual Basic 4 / 5 / 6)
- Problems on Insert and Update Statement (C#)
- Problems on Insert and Update (C#)
- Insert and Update Errors (C#)
- Error connecting to database (ASP.NET)
- sql statement (Visual Basic 4 / 5 / 6)
- syntax error: i cant find it..HELP! (ASP)
Other Threads in the ASP Forum
- Previous Thread: Need this help urgent please
- Next Thread: Dynamic XML
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7






