By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Access Error Message

P: 3
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,
Expand|Select|Wrap|Line Numbers
  1. 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 !
Jan 7 '10 #1
Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,186
From the error message I would guess that Session("IDSession") 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.
Jan 7 '10 #2

TheSmileyCoder
Expert Mod 100+
P: 2,321
1. What type of value is IDSession? is it a long? text? other?

2. Change your code to look like this:

Expand|Select|Wrap|Line Numbers
  1. mySQL = "SELECT * FROM Session WHERE IDSession = " & Session("IDSession")
  2. MsgBox "mySQL string:" & vbNewLine & mySQL 
or
Expand|Select|Wrap|Line Numbers
  1. mySQL = "SELECT * FROM Session WHERE IDSession = " & Session("IDSession")
  2. Debug.Print "mySQL string:" & mySQL 
Then post your full mySQL string here.
Jan 15 '10 #3

P: 3
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'
Jan 15 '10 #4

TheSmileyCoder
Expert Mod 100+
P: 2,321
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.
Jan 16 '10 #5

NeoPa
Expert Mod 15k+
P: 31,186
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.
Jan 17 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.