inicio mail me! sindicaci;ón

ADO abecedarian tutorial: ADO quickens script through GetString()

Author: The ASP script that uses GetString() method to quicken you please (the Response.Write that will replace much travel) .

Example

Use GetString()

How to use GetString() to show the data that records concentration in HTML form.

Much travel Response.Write

The example below demonstrated to demonstrate a kind of method that the database inquires in HTML form:

It is quotative content below:

<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.MoveNextLoop%>
</table>
<%Rs.closeConn.closeSet Rs = NothingSet Conn = Nothing
%>
</body>
</html>

For large to inquiry, make the processing time that can increase script so, because the server needs to handle many Response.Write order,this is.

Settlement way is to found all string, arrive from <table> </table> , output its next - use Response.Write only.

GetString() method

GetString() method makes us capable to use Response.Write only, can show all string. At the same time it does not need Do even. .loop code and conditional test come whether is servy record collect in EOF.

Syntactic

Str = Rs.GetString(format, rows, coldel, rowdel, nullexpr)

If need to use the data that comes from record volume to found form of a HTML, 3 when we need to make the parameter on in order to medium merely (all parameter are optional) :

Coldel - uses as the HTML of a separator

Rowdel - uses as the HTML of a separator

Nullexpr - should label the HTML that uses when sky

Annotate: The GetString() method is the character of ADO 2.0. You can download ADO 2.0 from the address below: Http://www.microsoft.com/data/download.htm

In the example below, we will use GetString() method, keep record market for a string:

It is quotative content below:

<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” , connStr=rs.GetString(, , "</td><td>" , "</td></tr><tr><td>" , " " )
%>
<table Border= "1" Width= "100%" >
<tr>
<td><%Response.Write(str)%></td>
</tr>
</table>
<%Rs.closeConn.closeSet Rs = NothingSet Conn = Nothing
%>
</body>
</html>

The variable Str above is including a string of all rows that return by SELECT statement and travel. In every </td><td> can appear between the row, in every </td></tr><tr><td> can appear between travel. Such, use Response.Write only, we got the HTML of need.

Bookmark:Digg Del.icio.us Reddit

Leave a Comment