Solved

ASP Syntax - missing operator

Posted on 2014-01-23
5
303 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 33

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 33

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 143

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…

808 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