Need ASP help!!!!

Need ASP help!!!!

am 14.04.2007 17:13:58 von Rae Kim

Hi,

I am trying to use ASP in html to retrieve and display data from an MS
Access database. I keep getting this error:

Microsoft JET Database Engine error '80040e14'

Syntax error (missing operator) in query expression 'PersonID='.

In relation to the following line of code in ASP:

strSQL = "SELECT * FROM Person WHERE PERSONID= " & Session("PersonID")

Can you please tell me what the missing operator is? I have tried
adding in parenthesis and nothing seems to work, and I do not see what
is wrong with the code.

Thank you!!!

Re: Need ASP help!!!!

am 14.04.2007 17:56:53 von exjxw.hannivoort

Rae Kim wrote on 14 apr 2007 in microsoft.public.inetserver.asp.db:

> Hi,
>
> I am trying to use ASP in html to retrieve and display data from an MS
> Access database. I keep getting this error:
>
> Microsoft JET Database Engine error '80040e14'
>
> Syntax error (missing operator) in query expression 'PersonID='.
>
> In relation to the following line of code in ASP:
>
> strSQL = "SELECT * FROM Person WHERE PERSONID= " & Session("PersonID")

Do:

' vbs
reponse.write strSQL
reponse.end

What do you see?

> Can you please tell me what the missing operator is? I have tried
> adding in parenthesis and nothing seems to work, and I do not see what
> is wrong with the code.
>
> Thank you!!!
>
>



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Need ASP help!!!!

am 15.04.2007 13:43:15 von PW

You need single-quotes around the PersonID value.

Instead of this ...
strSQL = "SELECT * FROM Person WHERE PERSONID= " & Session("PersonID")

It should be this ...
strSQL = "SELECT * FROM Person WHERE PERSONID= '" & Session("PersonID") &
"'"

Re: Need ASP help!!!!

am 15.04.2007 14:36:09 von reb01501

PW wrote:
> You need single-quotes around the PersonID value.
>
> Instead of this ...
> strSQL = "SELECT * FROM Person WHERE PERSONID= " & Session("PersonID")
>
> It should be this ...
> strSQL = "SELECT * FROM Person WHERE PERSONID= '" &
> Session("PersonID") & "'"

How do you know that? You're assuming PERSONID is a character field ... ?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Re: Need ASP help!!!!

am 15.04.2007 14:38:48 von reb01501

Rae Kim wrote:
> Hi,
>
> I am trying to use ASP in html to retrieve and display data from an MS
> Access database. I keep getting this error:
>
> Microsoft JET Database Engine error '80040e14'
>
> Syntax error (missing operator) in query expression 'PersonID='.
>
> In relation to the following line of code in ASP:
>
> strSQL = "SELECT * FROM Person WHERE PERSONID= " & Session("PersonID")
>
> Can you please tell me what the missing operator is? I have tried
> adding in parenthesis and nothing seems to work, and I do not see what
> is wrong with the code.
>
> Thank you!!!

We cannot debug a sql statement without knowing what it is. Showing us the
vbscript code that is supposed to generate the sql statement is only half
the battle. Put the following statements into your code right after the
above line of code, run the page and show us the result. Actually, you will
probably see the problem yourself when you do that.

response.write sql
response.end

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Re: Need ASP help!!!!

am 17.04.2007 18:08:12 von Daniel Crichton

Rae wrote on 14 Apr 2007 08:13:58 -0700:

> Hi,
>
> I am trying to use ASP in html to retrieve and display data from an MS
> Access database. I keep getting this error:
>
> Microsoft JET Database Engine error '80040e14'
>
> Syntax error (missing operator) in query expression 'PersonID='.
>
> In relation to the following line of code in ASP:
>
> strSQL = "SELECT * FROM Person WHERE PERSONID= " & Session("PersonID")
>
> Can you please tell me what the missing operator is? I have tried
> adding in parenthesis and nothing seems to work, and I do not see what
> is wrong with the code.
>
> Thank you!!!

From that error, I'd say Session("PersonID") is blank.

Dan