Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Posts
    1

    Unanswered: Syntax error (missing operator) in query expression

    I have this query in ASP to get data from Access Database.

    sql1="SELECT G1M40.G1A_Date, G1M40.G1A_Shift, G1M40.G1A_M+40mm1, G1M40.G1A_M+10mm1 " &_
    " FROM G1M40 WHERE G1M40.G1A_Date = #" & currdate & "#ORDER BY G1M40.G1A_Date"

    When I run the ASP page I get error:
    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'G1M40.G1A_M+40mm1'.

    I cannot change the column name of table. Please let me know if there is any other option.

  2. #2
    Join Date
    Sep 2003
    Location
    Newark, Vermont
    Posts
    20

    Re: Syntax error (missing operator) in query expression

    Code:
      sql1="SELECT G1M40.G1A_Date, G1M40.G1A_Shift, G1M40.G1A_M+40mm1, G1M40.G1A_M+10mm1 " &_
    " FROM G1M40 WHERE G1M40.G1A_Date = #" & currdate & "#ORDER BY G1M40.G1A_Date"
    # ORDER BY G1M40.G1A_Date
    Try spacing # and ORDER

    Originally posted by rohitrs
    I have this query in ASP to get data from Access Database.

    sql1="SELECT G1M40.G1A_Date, G1M40.G1A_Shift, G1M40.G1A_M+40mm1, G1M40.G1A_M+10mm1 " &_
    " FROM G1M40 WHERE G1M40.G1A_Date = #" & currdate & "#ORDER BY G1M40.G1A_Date"

    When I run the ASP page I get error:
    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'G1M40.G1A_M+40mm1'.

    I cannot change the column name of table. Please let me know if there is any other option.

  3. #3
    Join Date
    Nov 2003
    Posts
    76
    try using square bracket for field names when you have +,- or spaces.
    [G1M40].[G1A_M+40mm1], [G1M40].[G1A_M+10mm1]

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    Sivaroo is correct. When you are using key/reserved characters/words you need to put brackets around the objects name.

  5. #5
    Join Date
    Apr 2004
    Posts
    1
    Originally posted by rnealejr
    Sivaroo is correct. When you are using key/reserved characters/words you need to put brackets around the objects name.
    I'm having almost the same problem, can anybody figure out for me.
    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
    SQL = "SELECT count(*) as DateMatch FROM tblNotice WHERE DateNotie > '"&tempLastDate&"'" //tempLastDate has value 04/04/2004

    If I use this, SQL = "SELECT count(*) as DateMatch FROM tblNotice WHERE DateNotice > #04/04/2004# " //the result can be displayed out.

    If I use this, SQL = "SELECT count(*) as DateMatch FROM tblNotice WHERE DateNotie > '#"&tempLastDate&"'#"
    Syntax error in date in query expression 'DateNotie > '#4/4/2004'#'.

    i'm writing in asp code.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    "SELECT ... WHERE DateNotie > #"&tempLastDate&"#"

    no quotes for access date strings, just the hash marks
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •