SQL Statement Error?
am 18.01.2005 19:02:08 von Jim in Arizona
I'm trying to show the total number of votes for a specific set of
employees. I have one access2K DB with a single table called master. In that
table is two columns: ID and Vote. The vote column is the only one I'm
concerned about. I just need to list their names in one table column then
how many times their name has been listed in the next table column. I used
Access to build the SQL query and tried to incorporate that into my ASP
script but I don't think I'm doing it right (I must not be otherwise I
wouldn't be here).
Here's my error, which makes me think there's some kind of an endless loop
occuring. I realize that CountOfvote is not an actual field, but honestly, I
have no idea how to put the contents of that SQL variable into a readable
form within ASP.
Error Type:
Active Server Pages, ASP 0113 (0x80004005)
The maximum amount of time for a script to execute was exceeded. You can
change this limit by specifying a new value for the property
Server.ScriptTimeout or by changing the value in the IIS administration
tools.
/getvotes.asp
Here's my code.
<%@ Language=VBScript %>
<%
Option Explicit
Dim Conn, SQL1
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
server.mappath("topthree.mdb")
Set SQL1 = Conn.Execute("SELECT master.vote, Count(master.vote) AS
CountOfvote" & _
" FROM master" & _
" GROUP BY master.vote;")
%>
Untitled
<%
Response.Write "Employee Of The Year
"
Response.Write "Vote Totals for Top Four
"
Response.Write "
cellspacing=""0"" cellpadding=""7"" width=""90%"">"
Response.Write "Employee | |
valign=""bottom"">Votes
"
Do While NOT SQL1.EOF
Response.Write ""
Response.Write SQL1.Fields("vote") & " | "
Response.Write SQL1.Fields("CountOfvote") & " |
"
LOOP
Response.Write""
Conn.Close
SQL1.Close
Set Conn = Nothing
Set SQL1 = Nothing
%>
Thanks for the help.
Jim
Re: SQL Statement Error?
am 18.01.2005 19:28:52 von exjxw.hannivoort
Jim in Arizona wrote on 18 jan 2005 in microsoft.public.inetserver.asp.db:
> Do While NOT SQL1.EOF
> Response.Write "
"
> Response.Write SQL1.Fields("vote") & " | "
> Response.Write SQL1.Fields("CountOfvote") & " |
"
SQL1.MoveNext ' insert this, otherwise you get an endless loop
> LOOP
>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Re: SQL Statement Error?
am 18.01.2005 19:40:09 von Jim in Arizona
"Evertjan." wrote in message
news:Xns95E2C62C9E1CBeejj99@194.109.133.29...
> Jim in Arizona wrote on 18 jan 2005 in microsoft.public.inetserver.asp.db:
>
>> Do While NOT SQL1.EOF
>> Response.Write ""
>> Response.Write SQL1.Fields("vote") & " | "
>> Response.Write SQL1.Fields("CountOfvote") & " |
"
>
> SQL1.MoveNext ' insert this, otherwise you get an endless loop
>
>> LOOP
>>
>
>
>
> --
> Evertjan.
> The Netherlands.
> (Replace all crosses with dots in my emailaddress)
>
Thanks Evertjan. That did it. :)
Jim
Re: SQL Statement Error?
am 18.01.2005 21:11:01 von Jim in Arizona
> Set SQL1 = Conn.Execute("SELECT master.vote, Count(master.vote) AS
> CountOfvote" & _
> " FROM master" & _
> " GROUP BY master.vote;")
Is there a way to do an ORDER BY using the CountOfvote variable? This way,
on the page I have displaying the vote counts per person, I can have the
person with the highest vote count on top. I tried but I get an error:
GROUP BY master.vote ORDER BY CountOfvote;
The error I get:
Error Type:
Microsoft JET Database Engine (0x80040E10)
No value given for one or more required parameters.
/getvotes.asp, line 15
Thanks,
Jim
Re: SQL Statement Error?
am 18.01.2005 21:17:46 von Jim in Arizona
Nevermind, I figured it out!
GROUP BY master.vote ORDER BY Count(master.vote) DESC
Thanks,
Jim
"Jim in Arizona" wrote in message
news:OFefunZ$EHA.2608@TK2MSFTNGP10.phx.gbl...
>> Set SQL1 = Conn.Execute("SELECT master.vote, Count(master.vote) AS
>> CountOfvote" & _
>> " FROM master" & _
>> " GROUP BY master.vote;")
>
> Is there a way to do an ORDER BY using the CountOfvote variable? This way,
> on the page I have displaying the vote counts per person, I can have the
> person with the highest vote count on top. I tried but I get an error:
>
> GROUP BY master.vote ORDER BY CountOfvote;
>
> The error I get:
>
> Error Type:
> Microsoft JET Database Engine (0x80040E10)
> No value given for one or more required parameters.
> /getvotes.asp, line 15
>
>
> Thanks,
> Jim
>
>
>
>