Print Page | Close Window

major headache with SQL in ASP

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=11425
Printed Date: 31 March 2026 at 1:36am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: major headache with SQL in ASP
Posted By: ainsworth14
Subject: major headache with SQL in ASP
Date Posted: 04 August 2004 at 5:18pm

I am trying to run through an asp book i have but also trying to customize the lessons in there to my own personal needs.

i have created a database input form on addproduct.asp which then send info to manageproduct.asp for this page to process and add a record to my database.

when i try to add product i always get his annoying message saying:

  • Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
    /manageproducts.asp, line 50

    POST Data:
    id=12234&artist=artist&title=title&description=d esc&year=1224&label=label&format=12inch&catn umber=catnum&price=5.00&audio=audio&image=image& amp; amp;stock=3&addProduct=1

  • Time:
    Wednesday, August 04, 2004, 9:53:54 PM

  • More information:
    http://www.microsoft.com/ContentRedirect.asp?prd=iis&sbp=&pver=5.0&ID=500;100&cat=Microsoft+OLE+DB+Provider+for+ODBC+Drivers&os=&over=&hrd=&Opt1=&Opt2=%2D2147217900&Opt3=%5BMicrosoft%5D%5BODBC+Microsoft+Access+Driver%5D+Syntax+error+in+INSERT+INTO+statement%2E - Microsoft Support

 

but i cannot see anything wrong with the code here:

<%
'add new product
IF addProduct <> "" THEN

sqlString = "INSERT INTO record_webtest (ID, Artist, Title, Descrip, YR, Label, Format, Cat, Price GBP, Audio, Image, Stock) "&_
"VALUES ( " & id & "," &_
"'" & artist & "'," &_
"'" & title & "'," &_
"'" & descrip & "'," &_
yr & "," &_
"'" & label & "'," &_
"'" & format & "'," &_
"'" & catnumber & "'," &_
price & "," &_
"'" & audio & "'," &_
"'" & image & "'," &_
stock & ")"


Con.Execute sqlString **(LINE 50)**

%>

 

I have used response.write to get an output of the sql and it is absolutely fine:

INSERT INTO record_webtest (ID, Artist, Title, Descrip, YR, Label, Format, Cat, Price GBP, Audio, Image, Stock) VALUES ( 12234,'artist','title','desc',1224,'label','12inch','catnum' ,5.00,'audio','image',3)

can anyone advise me?

 

many thanks

mark




Replies:
Posted By: michael
Date Posted: 04 August 2004 at 6:00pm

There is a space between Price and BBP
 ...Cat, Price GBP, Audio, Image,...

if you change that the code is fine, if there in fact is a space in the table name (bad idea) enclose it in [] so [Price GBP] if not, take it out.



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: ainsworth14
Date Posted: 05 August 2004 at 1:52pm

YES!!

thanks very much, solved it, working fine now!

im new to ASP so overlooked that bit

mark




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net