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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting a table using ASP

Status
Not open for further replies.

williamsba

Programmer
Aug 3, 2000
57
US
Im trying to sort a table alphabetically by last name using ASP through Access.&nbsp;&nbsp;Heres is my code below...<br><br>&lt;% Response.buffer = true%&gt;<br>&lt;HTML&gt;<br>&lt;HEAD&gt;<br>&lt;TITLE&gt;Test&lt;/TITLE&gt;<br>&lt;/HEAD&gt;<br>&lt;BODY&gt;<br>&lt;% Dim rs<br>Set rs = Server.CreateObject (&quot;ADODB.Recordset&quot;)<br>rs.Open &quot;Personnel&quot;, &quot;DSN=TOManning&quot;<br><br>While Not rs.EOF<br>Response.Write &quot;SSN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: &quot; & rs(&quot;SSN&quot;) & &quot;&lt;BR&gt;&quot;<br>Response.Write &quot;First Name&nbsp;&nbsp;&nbsp;&nbsp;: &quot; & rs(&quot;FNAME&quot;) & &quot;&lt;BR&gt;&quot;<br>Response.Write &quot;Last Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: &quot; & rs(&quot;LNAME&quot;) & &quot;&lt;BR&gt;&quot;<br><br>Response.Write &quot;&lt;br&gt;&quot;<br>rs.MoveNext<br>Wend<br><br>rs.Close<br>Set rs = Nothing %&gt;<br>&lt;/BODY&gt;<br>&lt;/HTML&gt;<br><br>Now everything prints out perfect except I cant figure out how it is determining the order at which it prints out.&nbsp;&nbsp;There seems to be no order at all, because it picks the names and puts them in a random order.&nbsp;&nbsp;It doesnt even go down the table, but it does put up all of the info from the table.&nbsp;&nbsp;How can i get this alphabetized by last name? <br><br>Thank you<br><br>-Brad
 
Either open your table with a query instead of a table command:<br><br>ex: &quot;SELECT ssn, fname, lname FROM Personnel ORDER BY lname&quot;<br><br>Notice the Order By clause in the Query<br><br>OR sort your Recordset after you've opened it with a Table Command<br><br>ex: Rs.Sort (&quot;lname ASC&quot;)<br><br> <p> Jeff Friestman<br><a href=mailto: > </a><br><a href= View my Brainbench transcript</a><br>Brainbench 'Most Valuable Professional' for ASP<br>
Brainbench 'Most Valuable Professional' for JavaScript<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top