October 23, 2008 at 8:30 am
Giving the results into a table with the columns answer1, answer2, answer3, answer4, answer5,.. as "right" or "wrong". The first name and name is also included.
I am trying to get the totel of the right answers, for example 3 of 7 answers
<% select Case total
case when rs("answers1")= "right" then 1 else 0 end +
case when rs("answer2")= "right" then 1 else 0 end +
case when rs("answer3")= "right" then 1 else 0 end +
case when rs("answer4")= "right" then 1 else 0 end +
end select %>
the error message ist
Microsoft VBScript compilation error '800a0401'
Expected end of statement
case when rs("antwort1")= "richtig" then 1 else 0 end +
------------------------------------^
I have no idea yet.
October 23, 2008 at 9:53 am
I'm not sure why you posted this on a SQL Server forum when it is asp/VBScript error.
It looks like you are trying to what you really want is something like this:
This was supposed to be similar to what Lowell posted but putting the Less Than and Greater than symbols in the code block made it not work
Or, and my VBscript skills are really rusty so this is more psuedo code:
Dim i
Dim j
j = 0
i = 1
While i < rs.columns.count
If Left(rs(i).Name, 7) = "answers" then
If rs(i) = "right" Then
j = j + 1
End If
End If
i = i + 1
Loop
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 23, 2008 at 9:56 am
looks like you are trying to do a sum on the web page, which is NOT the same a s a sql statement running on the server.
on the server, the sql statement would be something like this:
<% total = total + iif(rs("answer1")= "right" ,1,0)
+ iif(rs("answer2")= "right" ,1,0)
+ iif(rs("answer3")= "right" ,1,0)
+ iif(rs("answer4")= "right" ,1,0)
Response.Write "Total Score:" & total %>
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply