PC Review


Reply
Thread Tools Rate Thread

ASp Results Problem

 
 
Ed Richter
Guest
Posts: n/a
 
      1st Apr 2004
I'm accessing data from a database and attempting to post it to a page in tabular form. The results includes the number of responses and average values of some of the columns of data.

I first created the query as shown below which seems to be working fine:


<%
Dim objConn
Dim rsobj

League = Request.Form("League")

Set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open Application("cwvo_ConnectionString")
Server.ScriptTimeOut = 600

Set rsObj= objConn.Execute("SELECT Team, Count(Team), Avg(Sportsmanship_Score), Avg(Coach_Score) FROM Sportsmanship WHERE League = '" & League & "' Group by Team ORDER BY Team ASC")

If rsObj.EOF <> true then

rsObj.MoveFirst()
WHILE rsObj.EOF <> true

%>



Next I put a table into the page and attempted to place the results into their respective columns. This is where the problem occurs. The first column rsObj("Team") works fine, but I know the way I'm attempting to write the results of the count and average columns is not in the correct format, but don't know what the correct format should be.


<tr>
<td width="231"><font face="arial,helv" size="3"><% = rsObj("Team") %></td>
<td width="127"><% = rsObj (Count("Team")) %>&nbsp;</td>
<td width="121"><% = rsObj(Avg("Sportsmanship_Score")) %>&nbsp;</td>
<td width="122"><% = rsObj(Avg("Coach_Score")) %>&nbsp;</td>
</tr>






<%


rsObj.MoveNext()
WEND

End IF


%>


</table>
</div>


I've used this basic method many times with satisfactory results when just posting the results, without doing any type of math operations. Apparently when perfoming operations like this, I need a different format??

Can someone explain what proper format for these types of operations should be?? Thanks!
 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      1st Apr 2004
After looking over your code, it seems that you may be experiencing an error
that is related to the columns in your query. Aggregate columns have to be
assigned an alias in your query, or you won't know what the derived column
name will be (the database will assign one that it makes up. Here's an
example:

Set rsObj= objConn.Execute("SELECT Team, Count(Team) AS TeamCount,
Avg(Sportsmanship_Score) AS SportsmanshipAverage, Avg(Coach_Score) As
CoachAverage FROM Sportsmanship WHERE League = '" & League & "' Group by
Team ORDER BY Team ASC")

Then you refer to the aliases in your code.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Ed Richter" <(E-Mail Removed)> wrote in message
news:4EKac.99343$(E-Mail Removed)...
I'm accessing data from a database and attempting to post it to a page in
tabular form. The results includes the number of responses and average
values of some of the columns of data.

I first created the query as shown below which seems to be working fine:


<%
Dim objConn
Dim rsobj

League = Request.Form("League")

Set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open Application("cwvo_ConnectionString")
Server.ScriptTimeOut = 600

Set rsObj= objConn.Execute("SELECT Team, Count(Team),
Avg(Sportsmanship_Score), Avg(Coach_Score) FROM Sportsmanship WHERE League =
'" & League & "' Group by Team ORDER BY Team ASC")

If rsObj.EOF <> true then

rsObj.MoveFirst()
WHILE rsObj.EOF <> true

%>



Next I put a table into the page and attempted to place the results into
their respective columns. This is where the problem occurs. The first
column rsObj("Team") works fine, but I know the way I'm attempting to write
the results of the count and average columns is not in the correct format,
but don't know what the correct format should be.


<tr>
<td width="231"><font face="arial,helv" size="3"><% =
rsObj("Team") %></td>
<td width="127"><% = rsObj (Count("Team")) %>&nbsp;</td>
<td width="121"><% = rsObj(Avg("Sportsmanship_Score"))
%>&nbsp;</td>
<td width="122"><% = rsObj(Avg("Coach_Score")) %>&nbsp;</td>
</tr>






<%


rsObj.MoveNext()
WEND

End IF


%>


</table>
</div>


I've used this basic method many times with satisfactory results when just
posting the results, without doing any type of math operations. Apparently
when perfoming operations like this, I need a different format??

Can someone explain what proper format for these types of operations should
be?? Thanks!


 
Reply With Quote
 
Ed Richter
Guest
Posts: n/a
 
      2nd Apr 2004
Your suggestion fixed it. I kind of figured that was the problem, but I
didn't know how to format the alias.

Your code took care of it nicely. Thanks for the help!



"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:OIqwiA$(E-Mail Removed)...
> After looking over your code, it seems that you may be experiencing an

error
> that is related to the columns in your query. Aggregate columns have to be
> assigned an alias in your query, or you won't know what the derived column
> name will be (the database will assign one that it makes up. Here's an
> example:
>
> Set rsObj= objConn.Execute("SELECT Team, Count(Team) AS TeamCount,
> Avg(Sportsmanship_Score) AS SportsmanshipAverage, Avg(Coach_Score) As
> CoachAverage FROM Sportsmanship WHERE League = '" & League & "' Group by
> Team ORDER BY Team ASC")
>
> Then you refer to the aliases in your code.
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Ed Richter" <(E-Mail Removed)> wrote in message
> news:4EKac.99343$(E-Mail Removed)...
> I'm accessing data from a database and attempting to post it to a page in
> tabular form. The results includes the number of responses and average
> values of some of the columns of data.
>
> I first created the query as shown below which seems to be working fine:
>
>
> <%
> Dim objConn
> Dim rsobj
>
> League = Request.Form("League")
>
> Set objConn = Server.CreateObject("ADODB.Connection")
>
> objConn.Open Application("cwvo_ConnectionString")
> Server.ScriptTimeOut = 600
>
> Set rsObj= objConn.Execute("SELECT Team, Count(Team),
> Avg(Sportsmanship_Score), Avg(Coach_Score) FROM Sportsmanship WHERE League

=
> '" & League & "' Group by Team ORDER BY Team ASC")
>
> If rsObj.EOF <> true then
>
> rsObj.MoveFirst()
> WHILE rsObj.EOF <> true
>
> %>
>
>
>
> Next I put a table into the page and attempted to place the results into
> their respective columns. This is where the problem occurs. The first
> column rsObj("Team") works fine, but I know the way I'm attempting to

write
> the results of the count and average columns is not in the correct format,
> but don't know what the correct format should be.
>
>
> <tr>
> <td width="231"><font face="arial,helv" size="3"><% =
> rsObj("Team") %></td>
> <td width="127"><% = rsObj (Count("Team")) %>&nbsp;</td>
> <td width="121"><% = rsObj(Avg("Sportsmanship_Score"))
> %>&nbsp;</td>
> <td width="122"><% = rsObj(Avg("Coach_Score")) %>&nbsp;</td>
> </tr>
>
>
>
>
>
>
> <%
>
>
> rsObj.MoveNext()
> WEND
>
> End IF
>
>
> %>
>
>
> </table>
> </div>
>
>
> I've used this basic method many times with satisfactory results when just
> posting the results, without doing any type of math operations.

Apparently
> when perfoming operations like this, I need a different format??
>
> Can someone explain what proper format for these types of operations

should
> be?? Thanks!
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Problem with Gridview and SP without results anr Microsoft ASP .NET 0 17th Feb 2009 03:34 PM
Search Results Problem =?Utf-8?B?ZWxlbWV0bmFsMzgxOQ==?= Windows XP General 5 18th Jul 2007 01:03 PM
problem w/ form results =?Utf-8?B?bWVnaA==?= Microsoft Frontpage 3 22nd Mar 2005 09:10 PM
DB Results Problem Rob Microsoft Frontpage 1 4th Jul 2004 05:07 AM
SUM problem with too many results Tom Drill Microsoft Excel Worksheet Functions 6 6th Apr 2004 01:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:40 PM.