Need ASP help!!!!

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!!!
Rae Kim [ Sa, 14 April 2007 17:13 ] [ ID #1687725 ]

Re: Need ASP help!!!!

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)
exjxw.hannivoort [ Sa, 14 April 2007 17:56 ] [ ID #1687726 ]

Re: Need ASP help!!!!

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") &
"'"
PW [ So, 15 April 2007 13:43 ] [ ID #1688236 ]

Re: Need ASP help!!!!

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"
reb01501 [ So, 15 April 2007 14:36 ] [ ID #1688237 ]

Re: Need ASP help!!!!

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"
reb01501 [ So, 15 April 2007 14:38 ] [ ID #1688238 ]

Re: Need ASP help!!!!

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
Daniel Crichton [ Di, 17 April 2007 18:08 ] [ ID #1690166 ]
Webserver » microsoft.public.inetserver.asp.db » Need ASP help!!!!

Vorheriges Thema: DIVIDE BY ZERO ERROR, WHEN RUN FROM ASP PAGE
Nächstes Thema: Code is executing twice