Skip to main content
Known Participant
July 29, 2010
Question

Syntax error (missing operator) in query expression

  • July 29, 2010
  • 1 reply
  • 808 views

Hi all

I am creating a couple of pages where a dynamic list is created from an access database and then products from that list are displayed, the user then has the option of clicking more details, this then should pass the KITID over to the details page, However when i click on the details page i get the following error

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'KitID = Kit 01'.

/classicclocks/Kieninger_gallery.asp, line 21

Here is the code from the page i am building, can anybody see anything obvious here

strKitID = Request.QueryString("KitID")
' If KitID does not exist then redirect to Gallery page
If strKitID = False Then
  Response.Redirect("kit_gallerytest.asp")
End If
' SQL Query for specific KitID details only
Dim objRS
Set objRS = Server.CreateObject ("ADODB.Recordset")
' Open new objRS
  strSQL = "SELECT KitID,ImgKitCatalogue,KitDescriptionShort FROM tblMovements WHERE KitID = " & strKitID & " ORDER BY KitID"
  objRS.Open strSQL, MM_dbConn_STRING,,,adCmdTable
  ' Get all rows from table and asign values to array for use in form
  Do While Not(objRS.EOF)
  Images = True
  fsImagesArray = objRS.GetRows()
    Const arrKitID = 0
    Const arrImgKitCatalogue = 1
    Const arrKitDescriptionShort = 2
  Loop
' Close objConn and objRS
objRS.Close
strSQL = "SELECT * From tblMovements WHERE KitID = " & strKitID
objRS.Open strSQL, MM_dbConn_STRING

thanks

John

This topic has been closed for replies.

1 reply

Participating Frequently
July 29, 2010

String values in a SQL where clause must be wrapped in quotes. Try this:

strSQL = "SELECT KitID,ImgKitCatalogue,KitDescriptionShort FROM tblMovements WHERE KitID = '" & strKitID & "' ORDER BY KitID"