Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

ASP Syntax - missing operator

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
bschwarting
Asked:
bschwarting
1 Solution
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
and to protect against sql injection:
mySQL3 = "UPDATE inventory SET quantity = currentqtyminus1 WHERE [productname] = '" & replace(Request.Form("productname"), "'", "''") & "'" 

Open in new window

0
 
GaryCommented:
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
 
bschwartingAuthor Commented:
thanks so much all!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now