CORRECT?? strSQL = "SELECT * from vocabulary where ID = " & Session("ID")

  • Thread starter Thread starter Robert Airton
  • Start date Start date
R

Robert Airton

I wonder if anybody can sort out this error for me.
I has someone write a little asp program for me but it sometimes gives the
error
Syntax error (missing operator) in query expression 'ID ='.

I am not technical and know nothing of ASP.
However it appears that it is in the first line of the following section:

strSQL = "SELECT * from vocabulary where ID = " & Session("ID")
'strDB="DBQ=" & Server.Mappath("db\dictionary.mdb") & ";Driver={Microsoft
Access Driver (*.mdb)};"
strDB = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.Mappath("db\dictionary.mdb") & ";" & _
"Persist Security Info = False"
Set DataConn = Server.CreateObject("ADODB.Connection")
Set RecordsetListUpd = Server.CreateObject("ADODB.recordset")
DataConn.Open strDB
RecordsetListUpd.Open strSQL,DataConn,3,3,adCmdText
RecordsetListUpd.Fields("Tested") = Session("WTested")
RecordsetListUpd.Fields("Correct") = Session("WCorrect")

Is there a " or something missing?

I have searched the web and FAQs for strSQL and found nothing.

Any hep appreciated.
Robert





Robert
 
Hi,

I suspect that the Session("ID") is not returning a value, or in ASP speak
nothing. In this case the resulting query would be

SELECT * from vocabulary where ID =

Which is clearly incorrect, you can test for this using something like the
following

id = Session("ID")
if (id is nothing) then
...
else
...
end if

Hope this helps
 
It's likely that Session("ID") is empty resulting in an incorect SQL
statement. Just write your strSQL string so that you can see what exactly
you are about to execute...

Patrice
 
The syntax is wrong. If you are querying a field that contains a string, it
must contain a ' before and after it.

Example:

select * from users where username = 'Steve'

If the session variable is Steve, then this would be the correct syntax:

select * from users where username = '" & session("User") & "'"

Steve
 
Back
Top