Create a Dynamic, Sortable, Pageable HTML table from a SQL Statement


Author: Devin Garlit

Version Compatibility: ASP

More information:
This is code for a dynamically created, sortable, pageable HTML table, this is a pretty stripped down version. Real simple, just call the procedure where you want the table, pass it a connection object and a SQL string, it will create an ADO recordset and fill it into an HTML table, it will be fully pageable and sortable by clicking the column head. You can also have the values in one column linkable to another page,(example being you have an offer number and you click it to go to a details page) You input the records per page, default sort order, and the HTML tables attributes.

This can be easily made to incorporate images for column heads and for navigation buttons(maybe i'll post that later if this get a good response) Please email me with any questions.

NOTE FROM FREEVBCODE.COM: In our testing, we found a few gotchas with this routine. First, do not include an ORDER BY clause in the SQL statement; always specify the fields to sort by as the 3rd parameter instead. Second, if you are using a JOIN statement where two fields in different tables have the same name, clicking on a column head to sort the table by that field name will fail unless you use an alias for one of them. Overall, however, this is a very useful function with lots of flexibility.

Instructions: Copy the declarations and code below and paste directly into your VB project.