syntax error: i cant find it..HELP!

Reply

Join Date: Jul 2005
Posts: 13
Reputation: balor is an unknown quantity at this point 
Solved Threads: 0
balor's Avatar
balor balor is offline Offline
Newbie Poster

syntax error: i cant find it..HELP!

 
0
  #1
Aug 7th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 107
Reputation: madmital is an unknown quantity at this point 
Solved Threads: 3
madmital madmital is offline Offline
Junior Poster

Re: syntax error: i cant find it..HELP!

 
0
  #2
Aug 11th, 2005
Syntax is:
INSERT INTO "tablename" VALUES('.......

Assuming 'cat' is a tablename:

  1. Dim cat, desc, author, strSQL
  2. cat = request.form("category")
  3. desc = request.form("description")
  4. author = request.form("by")
  5.  
  6. strSQL = "INSERT INTO " & cat & " VALUES ('" & trim(desc) & "', '" & trim(date()) & "', '" & trim(author) & "')"
  7. mySQLConn.Execute strSQL
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 89
Reputation: msaqib is an unknown quantity at this point 
Solved Threads: 1
msaqib msaqib is offline Offline
Junior Poster in Training

Re: syntax error: i cant find it..HELP!

 
0
  #3
Nov 7th, 2005
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]


Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the ASP Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC