2.2.11. ADO accelerates the script through GetString ()

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

Page Views: 35 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.

Principles, Technologies, and Methods of Geographic Information Systems

 102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.