|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ok, I am very much an amateur here but I am using a lot ASP to manage a db for the students I work with in a YMCA program. What do I need to change to be able to count and print the # of records (like on a roster)
<% fp_sQry="SELECT * FROM Results WHERE (Grade = 'Senior') ORDER BY Club ASC" fp_sDefault="Club=" fp_sNoRecords="No records returned." fp_sDataConn="2004" fp_iMaxRecords=256 fp_iCommandType=1 fp_iPageSize=125 fp_fTableFormat=True fp_fMenuFormat=False fp_sMenuChoice="" fp_sMenuValue="" fp_iDisplayCols=23 fp_fCustomQuery=True BOTID=0 fp_iRegion=BOTID %> Thanks, and I'll send you a tax deduction statement for your help! |
|
#2
|
|||
|
|||
|
This looks like a FrontPage DRW but a regular SQL statement could be
SELECT COUNT(*) AS MyCount FROM Results WHERE (Grade = 'Senior') Which will return the count of the records. |
|
#3
|
|||
|
|||
|
I tried that b4 I posted the message and it returned an error, do I just replace the existing select statement like this:
<% fp_sQry="SELECT COUNT(*) as MyCount FROM Results WHERE (Grade = 'Senior') ORDER BY Club ASC" fp_sDefault="Club=" fp_sNoRecords="No records returned." fp_sDataConn="2004" fp_iMaxRecords=256 fp_iCommandType=1 fp_iPageSize=125 fp_fTableFormat=True fp_fMenuFormat=False fp_sMenuChoice="" fp_sMenuValue="" fp_iDisplayCols=23 fp_fCustomQuery=True BOTID=0 fp_iRegion=BOTID %> or is it a new script? And then how do i display the results of the count? |
|
#4
|
||||
|
||||
|
You would replace the existing statement. To display the results, you will need to use the recordset object. http://www.w3schools.com/ado/ado_intro.asp is a tutorial on this subject.
|
|
#5
|
||||
|
||||
|
The SQL SELECT COUNT(*) statement can't be ordered by a non-valid field, I think that is what might be throwing the error.
You should use something like: fp_sQry="SELECT COUNT(*) as MyCount FROM Results WHERE (Grade = 'Senior')" (since Club wasn't SELECT'ed). Which gives the number of seniors. If, on the other hand, you are trying to print a numbered list of all the members, you need to identify (or create, if it doesn't already exist) a loop which prints each senior and relative information on a separate line. As part of the loop, you need to use an variable number which is incremented by one with each iteration of the loop. The number just gets printed (like the other information) at the beginning of the line (or wherever you need it...). |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > more counting for dummies |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|