Accelerating Scripts with GetString()
Please use the GetString() method to speed up your ASP scripts (instead of multiple lines of Response.Write).
Multiple Response.Write
The following example demonstrates a method to display database queries in an HTML table:
For a large query, this approach increases script processing time due to the server needing to process numerous Response.Write commands.
The solution is to create the entire string, from <table>
to </table>
, and then output it - using only one Response.Write.
GetString() Method
The GetString() method allows us to display all strings with just one Response.Write. It also eliminates the need for do..loop code and conditional tests to check if the recordset is at EOF.
Syntax
To create an HTML table using data from a recordset, we only need to use three of the parameters (all parameters are optional):
- coldel - HTML used as the column delimiter
- rowdel - HTML used as the row delimiter
- nullexpr - HTML used when a column is empty
Note: The GetString() method is a feature of ADO 2.0. You can download ADO 2.0 from the following address: http://www.microsoft.com/data/download.htm
In the following example, we will use the GetString() method to store the recordset as a string:
Example
The variable str above contains a string of all columns and rows returned by the SELECT statement. </td><td>
appears between each column, and </td></tr><tr><td>
appears between each row. This way, we obtain the required HTML with only one Response.Write.