Forums
This topic is locked
Dynamic Sort Query Help
Posted 17 May 2003 21:54:18
1
has voted
17 May 2003 21:54:18 Rikard Krvaric posted:
I am developing a website that is finally taking the leap to put its memberlist into an interactive community online. Members will be able to look up other members, etc.
I have a directory page, which simply lists everybody, sorted by lastname, firstname.
How do I create the links on top, that allow the users to sort by firstname, or state, or country, or even company they work at.
I am using MSSql2K. DWMX, and ASP.
Appreciate any help!
You've Been Blasted by King Richard
Replies
Replied 19 May 2003 14:07:33
19 May 2003 14:07:33 Lee Diggins replied:
Hi Rickard
I do this by making my stored procedures contain dynamic 'order by' including dynamic ASC DESC with defaults set by the asp page when loading the first time. The benefit of having dynamic ASC DESC is if you have a long list sorted ASC and you want something at the bottom, the user can then change to DESC order by and the items will appear near the top (A-Z, Z-A type of thing). The hyperlinks call the same page, but the recordset is now ordered differently.
Calling the stored procedure each time may not be the most efficient way of doing this, from the db point of view, but it works for me on low traffic sites.
Hopefully you can move forward from here, if not let me know and I'll expand further.
One more thing, use case statement in your sql so the decision making is done in your sp and then your not exposing your db layout by specifying column names etc using POST or GET.
Digga
Sharing Knowledge Saves Valuable Time!!!
Edited by - Digga the Wolf on 19 May 2003 14:10:07
I do this by making my stored procedures contain dynamic 'order by' including dynamic ASC DESC with defaults set by the asp page when loading the first time. The benefit of having dynamic ASC DESC is if you have a long list sorted ASC and you want something at the bottom, the user can then change to DESC order by and the items will appear near the top (A-Z, Z-A type of thing). The hyperlinks call the same page, but the recordset is now ordered differently.
Calling the stored procedure each time may not be the most efficient way of doing this, from the db point of view, but it works for me on low traffic sites.
Hopefully you can move forward from here, if not let me know and I'll expand further.
One more thing, use case statement in your sql so the decision making is done in your sp and then your not exposing your db layout by specifying column names etc using POST or GET.
Digga
Sharing Knowledge Saves Valuable Time!!!
Edited by - Digga the Wolf on 19 May 2003 14:10:07