Please use the GetString() method to speed up your ASP script (instead of multi-line Response.Write ).Multiline Response.Write
The following example demonstrates one way to display a database query in anHTML table:
<html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" set rs = Server.CreateObject("ADODB.recordset") rs.Open "SELECT Companyname, Contactname FROM Customers", conn %> <table border="1" width="100%"> <%do until rs.EOF%> <tr> <td><%Response.Write(rs.fields("Companyname"))%>td> <td><%Response.Write(rs.fields("Contactname"))%>td> tr> <%rs.MoveNext loop%> table> <% rs.close conn.close set rs = Nothing set conn = Nothing %> body> html> For a large query, this increases the processing time of the script because the server needs to handle a large number of Response.Write orders.
The solution is to create all the strings from the to and then output it - use it only once Response.Write . GetString () method
GetString() method enables us to use it only once Response.Write You can display all the strings And it doesn’t even need do..loop Code and conditional tests to check whether the recordset is in the EOF .
Grammar
str = rs.GetString(format,rows,coldel,rowdel,nullexpr)
To create an HTML table with data from the recordset, we only need to use three of the above parameters (all of which are optional):
-
coldel -HTML used as a column delimiter
-
rowdel -HTML used as a line delimiter
-
nullexpr -HTML used when the column is empty
Note: GetString() method is a feature of ADO 2.0. You can download ADO 2.0: http://www.microsoft.com/data/download.htm from the following address
In the following example, we will use the GetString() method to save the recordset as a string:
Example
<html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" set rs = Server.CreateObject("ADODB.recordset") rs.Open "SELECT Companyname, Contactname FROM Customers", conn str=rs.GetString(,,"","| "," ") %> <table border="1" width="100%"> <tr> <td><%Response.Write(str)%>td> tr> table> <% rs.close conn.close set rs = Nothing set conn = Nothing %> body> html> The variables above str contains information made up of SELECT statement returns a string of all columns and rows. Appears between each column that appears between each line .In this way, use it only once. Response.Write and we get the HTML weneed.
| | | |