PDA

View Full Version : Can't resolve syntax error in function


Spookster
03-15-2003, 01:27 AM
Ok im about to lose my mind here. ASP is driving me crazy faster than PHP.

I have this function:


Function getReport1(sid, date)
query = "SELECT Assessment.assessment_date, Assessment.score, Question.description, Question.question_num " &_
"FROM Assessment INNER JOIN Question ON Assessment.qid = Question.qid " &_
"WHERE Assessment.sid = " & sid & " AND Assessment.assessment_date = " & date
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConn
Set RS = objConn.execute(query)
result = "<table>"
Do while not RS.eof
result = result & "<tr><td>" & RS("question_num") & "</td>"
result = result & "<td>" & RS("description") & "</td>"
result = result & "<td>" & RS("assessment_date") & "</td>"
result = result & "<td>" & RS("score") & "</td></tr>"
RS.movenext
Loop
result = result & "</table>"
Call CloseAll
getReport1 = result
End Function


I keep getting an error stating incorrect syntax near keyword AND.

I don't see the error. :(

Spookster
03-15-2003, 02:16 AM
It works if I hardcode the values in there:


"WHERE Assessment.sid = 1 AND Assessment.assessment_date = '3/1/2003'"


why does it all of a sudden have a problem with my variables?

Spookster
03-15-2003, 03:24 AM
Ok I don't think the problem is with the function anymore. Somehow the first argument is not being given a value where I call the function.

I'm off to go do some more debugging. Grrrrrrrr ASP.

Spookster
03-15-2003, 03:51 AM
Ok problem finally solved. I was storing a value in a session and was overwriting that value with a null before it got passed to the function.