Forums
This topic is locked
Using sorting commands/stored procedures.
03 Dec 2001 22:27:12 Q Qwerty posted:
I need to do the following: I have a database with a lot of data. Now I want users to sort the data on certain criteria. You've all seen them, result pages with on top of the table a 'command' which says, "sort on price" or "sort on entry date". I know some can be done with some SQL statement, but I only know how to do this by building different pages with the SQL in the recordset. That's not what I want because it would take me ages to do so and I know there's an easier way. I once saw a tutorial on this but I never managed to retrieve it. Now my question is: is the above done with a stored procedure or whatever and could somebody explain it, or does anyone know where to find such tutorial. Again, thanks to everyone who replies.Rein
Replies
Replied 04 Dec 2001 09:03:01
04 Dec 2001 09:03:01 Viktor Farcic replied:
Create SQL with last line like:
ORDER BY varOrder ASC
Create variable with name varOrder, put default value to be name of the field that will be sorted by default and Run-Time Value like Request("Order".
Create links to the same page like: index.asp?Order=Title (in this example records will be sorted by field Title).
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I need to do the following: I have a database with a lot of data. Now I want users to sort the data on certain criteria. You've all seen them, result pages with on top of the table a 'command' which says, "sort on price" or "sort on entry date". I know some can be done with some SQL statement, but I only know how to do this by building different pages with the SQL in the recordset. That's not what I want because it would take me ages to do so and I know there's an easier way. I once saw a tutorial on this but I never managed to retrieve it. Now my question is: is the above done with a stored procedure or whatever and could somebody explain it, or does anyone know where to find such tutorial. Again, thanks to everyone who replies.
Rein
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
ORDER BY varOrder ASC
Create variable with name varOrder, put default value to be name of the field that will be sorted by default and Run-Time Value like Request("Order".
Create links to the same page like: index.asp?Order=Title (in this example records will be sorted by field Title).
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I need to do the following: I have a database with a lot of data. Now I want users to sort the data on certain criteria. You've all seen them, result pages with on top of the table a 'command' which says, "sort on price" or "sort on entry date". I know some can be done with some SQL statement, but I only know how to do this by building different pages with the SQL in the recordset. That's not what I want because it would take me ages to do so and I know there's an easier way. I once saw a tutorial on this but I never managed to retrieve it. Now my question is: is the above done with a stored procedure or whatever and could somebody explain it, or does anyone know where to find such tutorial. Again, thanks to everyone who replies.
Rein
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Replied 04 Dec 2001 20:55:42
04 Dec 2001 20:55:42 Q Qwerty replied:
It works fine, but I've one more questions. How can I define which ORDER statement is used, ASC or DESC by default, and I mean for different columns? For example I want "Price" to be sorted ASC and "Company" DESC. I've seen some site's which sort again the opposite by clicking another time on the sort link. That would be fine too. Thanks again.
Rein
Rein
Replied 04 Dec 2001 23:32:07
04 Dec 2001 23:32:07 Owen Eastwick replied:
Something like:
varOrderBy = Request.QueryString("OrderBy"
then:
RecordsetName.Source = "SELECT * FROM YourTable ORDER BY " & varOrderBy
Then have image or text links at the top of the table columns something like:
<a href="SamePage.asp?OrderBy=ORDER+BY+YourFieldName+ASC">Ascending</a>
<a href="SamePage.asp?OrderBy=ORDER+BY+YourFieldName+DESC">Descending</a>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
varOrderBy = Request.QueryString("OrderBy"
then:
RecordsetName.Source = "SELECT * FROM YourTable ORDER BY " & varOrderBy
Then have image or text links at the top of the table columns something like:
<a href="SamePage.asp?OrderBy=ORDER+BY+YourFieldName+ASC">Ascending</a>
<a href="SamePage.asp?OrderBy=ORDER+BY+YourFieldName+DESC">Descending</a>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo