2.2.11. ADO accelerates the script through GetString ()

发布时间 : 2025-10-25 13:35:19 UTC      

Page Views: 9 views

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.
《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。