homepage Welcome to WebmasterWorld Guest from 54.205.144.54
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
ORDER BY field name ASC (sorting Access DB results)
fototex




msg:4155559
 11:20 am on Jun 20, 2010 (gmt 0)

Hi Webmasters,

I am using a poll from which I can get the poll results from my Access Db properyl by the following code:



<td width="100%">
<%DO UNTIL rsAnswer.EOF%>
<%percent = FormatPercent(rsAnswer("total_votes")/rsPoll("total_votes"),0)%>
<table width="100%" cellspacing="0" height="15">
<tr>
<td width="350" style="width: 125" class="style1" size="10px">
<%=rsAnswer("total_votes")%><span class="style2">Vote(s)</span> </td>
<td width="350" style="width: 200" class="style4">
<img src="votes.gif" width="<%=percent%>" height="20" class="style5">
</td>
<td Align="right" class="style3" style="width: 125">
<strong> <%=rsAnswer("answer")%></strong>
</td>
</tr>
</table>
<%rsAnswer.MoveNext%>
<%LOOP%>
</td>


The code represents the results of the votes and also the total number of votes for each question. (variable total_votes)
It works properly but what I am trying to achieve is to sort the results by the variable (total_votes) descending. I mean that the most voted question or result lies at the top and continues with the next most voted question in the next line.

have been trying to sort it out with (ORDER BY total_votes ASC) at the end of %LOOP% but it did not work.

Any comments about the correct usage of the code is appreciated.

Thank you for your time & comments.

 

mattur




msg:4155565
 11:52 am on Jun 20, 2010 (gmt 0)

"ORDER BY total_votes ASC" needs to be in your SQL statement, i.e. the database query used to open rsAnswer. HTH

fototex




msg:4156170
 6:14 pm on Jun 21, 2010 (gmt 0)

Have done it so, works great!
Thank you very much mattur.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved