Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display number of "Yes" and "No" answers in a survey

Status
Not open for further replies.

joshbula

Technical User
Nov 19, 2004
45
US
I am very novice at asp and SQL, please help point me in the right direction:

I am using ASP JSCRIPT and SQL Server 2000
Table name is dbo.survey
Field name is q1
Each record has either "Yes" or "No" for this field.

I want to display how many "Yes" and "No" answers there are like this:

1. Should DISTRICT CONCERT BAND MPA include a clinic session for each band immediately following sight reading?
Yes: insert number of "Yes" answers here
No: insert number of "No" answers here

Here's what is in the body of the code underneath the question:

[tt]

Yes: <%=(SELECT COUNT(q1) FROM dbo.survey WHERE q1='Yes';)%>
No: <%=(SELECT COUNT(q1) FROM dbo.survey WHERE q1='Yes';)%>
[/tt]

I'm getting this error:
Microsoft JScript compilation (0x800A03EE)
Expected ')'

What am I doing wrong?
 
Specifically on what line is the error occurring? From what you have shown, everything appears to be ok. Though you might want to change the second line where you set the value for No. Try this:
Code:
Yes: <%=(SELECT COUNT(q1) FROM dbo.survey WHERE q1='Yes';)%>
No: <%=(SELECT COUNT(q1) FROM dbo.survey WHERE q1='[COLOR=red]No[/color]';)%>
Otherwise, the problem lies somewhere else in your code. Typically what is happening is that you have forgotten an ending parenthetical bracket somewhere. Determine what line the error is occurring on and then track it from there.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
The error is on line 252, which is the first line of the code above:
Code:
Yes: <%=(SELECT COUNT(q1) FROM dbo.survey WHERE q1='Yes';)%>

Thanks,
...Josh
 
Ok, maybe I'm unclear here, but are you expecting this to return the actual count? Because all you've done is create the SQL string, but I don't see where you're actually returning a recordset (the actual count) by connecting to your database and creating the recordset returned by that SQL string.

Unless there is some other relevant code that is not here. Could you please clarify?

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top