0

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

3
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by msaqib
0

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
0

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]


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.