DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP (http://www.daniweb.com/forums/forum62.html)
-   -   syntax error: i cant find it..HELP! (http://www.daniweb.com/forums/thread30018.html)

balor Aug 7th, 2005 9:40 pm
syntax error: i cant find it..HELP!
 
this is the error:
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
/proj/save.asp, line 26

====

this is my insert into statement:

Dim cat, desc, author, strSQL
cat = request.form("category")
desc = request.form("description")
author = request.form("by")

strSQL = "INSERT INTO " & cat & " (description,ddate,by) VALUES ("
strSQL = strSQL & "'" & trim(desc) & "', "
strSQL = strSQL & "'" & trim(date()) & "', "
strSQL = strSQL & "'" & trim(author) & "') "
mySQLConn.Execute strSQL

madmital Aug 11th, 2005 5:43 am
Re: syntax error: i cant find it..HELP!
 
Syntax is:
INSERT INTO "tablename" VALUES('.......

Assuming 'cat' is a tablename:

Dim cat, desc, author, strSQL
cat = request.form("category")
desc = request.form("description")
author = request.form("by")

strSQL = "INSERT INTO " & cat & " VALUES ('" & trim(desc) & "', '" & trim(date()) & "', '" & trim(author) & "')"
mySQLConn.Execute strSQL

msaqib Nov 7th, 2005 12:09 am
Re: syntax error: i cant find it..HELP!
 
Syntax error in INSERT INTO statement.
This commonly occurs when your field name is a reserved word. Adjust your field names and SQL statement accordingly and you should avoid the problem.

If you can't adjust your fieldnames you can use [ ] marks to delimit the field names, eg
INSERT INTO table1
([field], [password])
VALUES ('value1', 'value2')

See you have the field name 'by' you should use it like [by]




All times are GMT -4. The time now is 4:32 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC