Access Error Message

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • misterb
    New Member
    • Jan 2010
    • 3

    Access Error Message

    Hi

    I get the following error message:

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

    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'IDSession ='


    Here is the corresponding line of code from the ASP page,
    Code:
    mySQL = "SELECT * FROM Session WHERE IDSession = " & Session("IDSession")
    Can someone please explain why i am getting this error? I have looked at some other examples, but so far, have not solved my problem

    Thanks !
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    From the error message I would guess that Session("IDSess ion") resolves to an empty string or Null.

    See below for some general guidelines on such a situation :
    One of the most popular (frequently occurring rather than best liked) problems we get is with SQL strings being manipulated in VBA code.

    The reason this is so difficult is that all the work is being done at a level of redirection. What I mean by this is that the coder is never working directly with the SQL itself, but rather with code which in turn, is relied on to produce the SQL that they are envisaging is required. It's rather similar to the problems coders have historically had dealing with pointers.

    Anyway, a technique I often suggest to coders struggling with this (at any level. This happens to experienced coders too.) is to use either the MsgBox() function, or Debug.Print into the Immediate Pane of the debugger window, to display the value of the SQL in the string before using it (That's assuming you're not good with debugging generally. Personally I would trace to the line, then display the value prior to allowing execution of the string - See Debugging in VBA). It's really much easier to appreciate what a SQL string is meant to do, and where there may be problems, when you can see it in its entirety, and in its true form, rather than as the code is about to create it.

    Comment

    • TheSmileyCoder
      Recognized Expert Moderator Top Contributor
      • Dec 2009
      • 2322

      #3
      1. What type of value is IDSession? is it a long? text? other?

      2. Change your code to look like this:

      Code:
      mySQL = "SELECT * FROM Session WHERE IDSession = " & Session("IDSession")
      MsgBox "mySQL string:" & vbNewLine & mySQL
      or
      Code:
      mySQL = "SELECT * FROM Session WHERE IDSession = " & Session("IDSession")
      Debug.Print "mySQL string:" & mySQL
      Then post your full mySQL string here.

      Comment

      • misterb
        New Member
        • Jan 2010
        • 3

        #4
        thanks for your suggestion to debug my problem with IDSession, however, neither approach worked as I get the following error messages. I though the debug should work, am I doing something else wrong?


        Microsoft VBScript runtime error '800a0046'

        Permission denied: 'MsgBox'


        Microsoft VBScript runtime error '800a01b6'

        Object doesn't support this property or method: 'Debug.Print'

        Comment

        • TheSmileyCoder
          Recognized Expert Moderator Top Contributor
          • Dec 2009
          • 2322

          #5
          My bad,
          I didn't notice you writing it was ASP. I thought it was VBA code from within Access. Sorry but I don't know anything about ASP.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32656

            #6
            MisterB, you have not explained even the environment you're working within. Maybe this is why you've never had a decent answer to your question. Your question is missing many of the important details required even to understand it.

            In this forum we mainly deal with VBA. My suggestions earlier were for developing within that evironment. I can see you're using VBScript, but that can be used in various environments. Without knowing these basic details we cannot begin to help effectively. I have some (very limited) experience with VBScript within the Windows Scripting Host, but that won't help you if you're doing web development for instance.

            Comment

            Working...