Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 11th, 2006, 07:20 PM
Registered User
 
Join Date: Apr 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default "Syntax error in INSERT INTO statement"

My SQL/ASP is a bit rusty, so it may be an obvious answer, but why do I get "Syntax error in INSERT INTO statement." with this query:
strSQL="INSERT INTO news (title,summary,article,author,date,time) VALUES('"&title&"','"&summary&"','"&article&"','"& username&"','"&date()&"','"&time()&"')"

where title, summary, article, and username are all short strings?

(strSQL resolves to the following)
INSERT INTO news (title,summary,article,author,date,time) VALUES('AH','AHGFHFG','asdsa','jtmerchant','4/11/2006','7:19:03 PM')

 
Old April 12th, 2006, 02:30 PM
Registered User
 
Join Date: Apr 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ah, I figured it out- 2 of my field names are reserved words (date and time). To solve it I simply put brackets [] around the field names.
strSQL="INSERT INTO news (title,summary,article,author,[date],[time]) VALUES('"&title&"','"&summary&"','"&article&"','"& username&"','"&date()&"','"&time()&"')"






Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax error in INSERT INTO statement mega ASP.NET 1.0 and 1.1 Basics 3 January 12th, 2005 04:30 PM
Syntax error in INSERT INTO statement. askaggs Classic ASP Databases 5 June 10th, 2004 12:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.