How to sort the records in Ascending or Descending?
The Sort method in the Recordset object can be used to set which column to perform the ascending or descending sorting; but the CursorLocation properties must be set to adUseClient.
The ASP codes are written and described as below:
<% Set conn = Server.CreateObject("Adodb.Connection") conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb") Set rs = Server.CreateObject("Adodb.Recordset") rs.CursorLocation = 3 'Set the CursorLocation = adUseClient rs.Open "Member",conn,1,3 If rs.EOF Then 'If Eof is True; that means is empty recordset %> <% Else rs.Sort = "Location ASC" 'Sorting the Location fields in Ascending 'If you need to sort in Descending; you need to change the word "ASC" to "DESC" Do while Not rs.eof %> <% rs.movenext Loop End If rs.Close Set rs = Nothing %>
No member...
<%=rs("MemID")%> <%=rs("MemberName")%> <%=rs("Location")%>
No comments:
Post a Comment