Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Syntax error (missing operator) in query expression

New Here ,
Jul 29, 2010 Jul 29, 2010

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

TOPICS
Server side applications
806
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 29, 2010 Jul 29, 2010
LATEST

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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines