Hello! I have been regularly updating a website for a client, but I really only work in HTML or Flash. The client has a problem with the ASP side of their site, and has asked me for help. I don't really know anything about databases or query languages, and I'm not even sure what I am looking at. I did not write this code in question. The issue occurs when I am trying to upload an image. I am able to select the image no problem, but when I click the upload button, I receive this error:

Microsoft JET Database Engine error '80040e14'
Syntax error (missing operator) in query expression 'product_id ='.
/admin/update_product_image.asp, line 33

Here is the entire code sample:

<!--#include file="include/include.inc"-->
'CheckAdminLogin ()

'  Variables
   Dim mySmartUpload
   Dim intCount

'  Object creation
   Set mySmartUpload = Server.CreateObject("Persits.Upload")

'  Upload
'   mySmartUpload.Upload

'  Save the files with their original names
'    intCount = mySmartUpload.Save("C:\Inetpub\www.website.com\products")
'    intCount = mySmartUpload.Save("c:\website\www\products")


'Save the file info in the DB
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Session ("ConnectionString")

SQL = "UPDATE products " & " SET product_image = '" & MySmartUpLoad.Files(1).FileName & "'WHERE product_id =" & product_id

response.redirect "edit_product.asp?product_id=" & product_id


I've been searching online and through these forums to no avail. Any assistance would be greatly appreciated. I'm sure it's just a small error that I don't recognize. Thanks very much!

Recommended Answers

All 3 Replies

If productid is non-numeric type then,

SQL = "UPDATE products SET product_image = '" & MySmartUpLoad.Files(1).FileName & "' WHERE product_id ='" & product_id & "'"

Thanks for your response, I appreciate it. The product_id is actually a number. It will only be 1 or 2, in this case it's a 1. I tried your code and it gave me a data type mismatch error. What would be the way to alter the code for numeric values?

It looks like adatapost was headed in the right direction....The first thing I would check is to make sure all of your values you are passing into the query are what you think they are....

Response.Write "Filename ::: " & MySmartUpLoad.Files(1).FileName & "<br />" & vbCrLf

Response.Write "Product ID ::: " & product_id & "<br />" & vbCrLf

then after you define your SQL value, I would write it out to the page, then add a Response.End so you can view it...like below.

SQL = "UPDATE products SET product_image = '" & MySmartUpLoad.Files(1).FileName & "' WHERE product_id =" & product_id & " "

Response.Write "SQL ::: " & SQL & "<br />" & vbCrLf


Copy the query displayed on the page and run it in query analyser to make sure it works. Once you're sure the query works, remove (or comment out) the Response lines and let the page run all the way through....if the query is valid, you shouldn't get any errors.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.