ASP ADO GetString function and using GetString to improve ASP's speed 1th/2 page _ Application Tips

Source: Internet
Author: User
Tags constant define null
The Rs.getstring method getstring the function of returning the specified recordset as a string. You can use this method to add an HTML table to an ASP file.
GetString method Syntax
Set str=objrecordset.getstring (format,n,coldel,rowdel,nullexpr)
parameter Parameters Description Description
Format Optional. A stringformatenum value that specifies the format when retrieving a Recordset as a string
Optional parameters. Specify a
N

Optional. The number of rows to is converted in the Recordset
Recordsetstringformatenum value. It is used to specify the format for extracting recordsets

Coldel Optional. The If format is set to adclipstring it is a column delimiter. Otherwise it is the tab character
Optional parameters. If the format[format value is set to adClipString, then it is a column-defining character; In addition, it is a tab[tab]
Rowdel Optional. The If format is set to adclipstring it is a row delimiter. Otherwise it is the carriage return character
Optional parameters. Optional parameters. If the format[format value is set to adClipString, then it is a row-defining character; In addition, it is a carriage return [carriage returns]
nullexpr Optional. The If format is set to adclipstring it's an expression used instead of a null value. Otherwise it is a empty string
Optional parameters. Optional parameters. If the format[format value is set to adClipString, then it is an expression that replaces the null value, except that it is a null character
Case
To create an HTML table with data from a recordset, we have need to use three of the parameters above:
We can create an HTML-formatted recordset datasheet by just one of the three parameters above:

Coldel-the HTML to use as a column-separator
coldel– use HTML format as column separator
Rowdel-the HTML to use as a row-separator
rowdel– using HTML format line delimiters
Nullexpr-the HTML to use if a column is NULL
nullexpr– If column is empty, use HTML
Note:the GetString () is an ADO 2.0 feature.
In the following case, we will use the GetString () method to retain the recordset as a string:

Copy Code code as follows:

<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.close
Conn.close
Set rs = NothingSet conn = nothing%></body>

Constant
Constant
Value
Value
Description
Describe
adClipString 2 delimits rows by the Rowdel parameter, columns by the Coldel parameter, and null values by the NULLEXPR
Specify Rowdel parameters to define rows (records), define columns (fields) by Coldel parameters, and define null values by NULLEXPR parameters
Current 1/2 page 12 Next read the full text
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.