Help -- (missing operator) in query expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shizuka
    New Member
    • Jul 2008
    • 2

    Help -- (missing operator) in query expression

    Hi! I'm really new to asp and getting this error on our webcalendar page. This error just started happening with no changes made to the page.. have any ideas??

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Cal_User_ID ='.
    /webcalendar/calendar.asp, line 1593


    Thanks in advance!
    ----------------------------------------------
    Code:
     
    If UseSQLServer = "YES" then
    		SQLc = "SELECT Cal_User_EventColor FROM Cal_User WHERE Cal_User_ID = " & Session("Cal_User_ID") 
    Else
    		SQLc = "SELECT Cal_User_EventColor FROM Cal_User WHERE Cal_User_ID = " & Session("Cal_User_ID")
    End If
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Shizuka,

    Welcome to Bytes! I hope you find the site useful.

    I hope you don't mind but I've editied your post to remove the 1500 + lines of code that you printed - it didn't make it very readable! I've left in the relevant lines of code that are causing you the problem.

    I think the problem here is that your Session("Cal_Us er_ID") variable doesn't contain a value at this point so your query is throwing a syntax error. You should test whether it contains a value prior to building the SQL string and insert a default value if not.

    Hope this helps,

    Dr B

    Comment

    • jeffstl
      Recognized Expert Contributor
      • Feb 2008
      • 432

      #3
      OP -

      Try this before that line of code.

      Code:
      if Session("Cal_User_ID") = "" or IsNull(Session("Cal_User_ID")) then
           'the Value of Session("Cal_User_ID") is blank and cannot run in the query!
      else
           'continue to the query
      end if
      By the way if this happened suddenly without any changes at all, then a change happen somewhere else I can promise you.

      Somewhere whatever function or code used to populate Session("Cal_Us er_ID") with a value is no longer doing it properly.....OR a particular set of user actions is causing it to not be populated. Or if the value was brought in from a database make sure that has not changed as well.

      One more note......the SQL appears to indicate that Session("Cal_Us er_ID") is supposed to be a number, so make sure it is numeric as well.

      Comment

      • Shizuka
        New Member
        • Jul 2008
        • 2

        #4
        Hi! Thanks so much for all the help.. That worked, i set Cal_User_ID equal to 22 which was the guest user in the database and its back up and working.. Sorry about all the code hehe.. Thanks!

        Shizuka

        Comment

        Working...