Solved

ASP Syntax - missing operator

Posted on 2014-01-23
5
300 Views
Last Modified: 2014-01-23
Frustrating day today, I can't seem to find any of my errors.  Can someone assist please?

mySQL3 = "UPDATE inventory SET quantity = currentqtyminus1 WHERE [productname] = " & Request.Form("productname")

Open in new window


error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '[productname] = Test Product'.
/triplels/insertDBsale.asp, line 64
0
Comment
Question by:bschwarting
5 Comments
 
LVL 32

Expert Comment

by:Big Monty
ID: 39804954
mySQL3 = "UPDATE inventory SET quantity = currentqtyminus1 WHERE [productname] = '" & Request.Form("productname") & "'"

Open in new window


if you had looked at and tried to implement my code with parameterized queries from your last post, you would not be having these problems
0
 
LVL 32

Accepted Solution

by:
Big Monty earned 500 total points
ID: 39804958
and if currentqtyminus1 is a asp local variable and not a column in your database, it would be:

mySQL3 = "UPDATE inventory SET quantity = " & currentqtyminus1 & " WHERE [productname] = '" & Request.Form("productname") & "'"

Open in new window

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39804966
and to protect against sql injection:
mySQL3 = "UPDATE inventory SET quantity = currentqtyminus1 WHERE [productname] = '" & replace(Request.Form("productname"), "'", "''") & "'" 

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 39804978
No points for this as Monty has answered the question but...
If you are just decreasing the quantity by 1 every time you can do

mySQL3 = "UPDATE inventory SET quantity =quantity -1  WHERE [productname] = '" & Request.Form("productname") & "'"
0
 
LVL 1

Author Comment

by:bschwarting
ID: 39805024
thanks so much all!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now