asp ADO GetString函數(shù)與用GetString來(lái)提高ASP的速度第1/2頁(yè)
更新時(shí)間:2007年12月21日 20:05:34 作者:
沒想到asp下有g(shù)etstring這個(gè)東西,看樣子不熟悉這塊啊,以后考慮用這個(gè),應(yīng)該不錯(cuò),另外還有g(shù)etrows等,都是asp下提高性能不錯(cuò)的函數(shù)。
rs.getstring的方法GetString的作用是:以字符串的形式返回指定的記錄集??梢允褂眠@個(gè)方法向ASP文件中添加HTML表格。
getstring 方法語(yǔ)法
Set str=objRecordset.GetString(format,n,coldel,rowdel,nullexpr)
案例
To create an HTML table with data from a recordset, we only need to use three of the parameters above:
我們只要通過上述三個(gè)參數(shù)中的一個(gè)就可以創(chuàng)建HTML格式的記錄集數(shù)據(jù)表:
coldel - the HTML to use as a column-separator
coldel – 使用HTML格式作為列分隔符
rowdel - the HTML to use as a row-separator
rowdel – 使用HTML格式行分隔符
NullExpr - the HTML to use if a column is NULL
NullExpr – 如果列為空,則使用HTML
Note: The GetString() method is an ADO 2.0 feature.
在下面的案例中,我們將使用GetString()方法將記錄集以一個(gè)字符串的形式保留:
<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.close
conn.close
set rs = Nothingset conn = Nothing%></body>
</html>
getstring 方法語(yǔ)法
Set str=objRecordset.GetString(format,n,coldel,rowdel,nullexpr)
| Parameter參數(shù) | Description描述 |
|---|---|
| format | Optional. A StringFormatEnum value that specifies the format when retrieving a Recordset as a string 可選參數(shù)。指定一個(gè) |
| n |
Optional. The number of rows to be converted in the Recordset |
| coldel | Optional. If format is set to adClipString it is a column delimiter. Otherwise it is the tab character 可選參數(shù)。如果format[格式]值設(shè)置為adClipString,那么它就是一個(gè)列界定符;除此之外,它便是一個(gè)tab[制表符] |
| rowdel | Optional. If format is set to adClipString it is a row delimiter. Otherwise it is the carriage return character 可選參數(shù)??蛇x參數(shù)。如果format[格式]值設(shè)置為adClipString,那么它就是一個(gè)行界定符;除此之外,它便是一個(gè)carriage return [回車符] |
| nullexpr | Optional. If format is set to adClipString it is an expression used instead of a null value. Otherwise it is an empty string 可選參數(shù)??蛇x參數(shù)。如果format[格式]值設(shè)置為adClipString,那么它就是一個(gè)用于替代空值的表達(dá)式;除此之外,它便是一個(gè)空字符 |
To create an HTML table with data from a recordset, we only need to use three of the parameters above:
我們只要通過上述三個(gè)參數(shù)中的一個(gè)就可以創(chuàng)建HTML格式的記錄集數(shù)據(jù)表:
coldel - the HTML to use as a column-separator
coldel – 使用HTML格式作為列分隔符
rowdel - the HTML to use as a row-separator
rowdel – 使用HTML格式行分隔符
NullExpr - the HTML to use if a column is NULL
NullExpr – 如果列為空,則使用HTML
Note: The GetString() method is an ADO 2.0 feature.
在下面的案例中,我們將使用GetString()方法將記錄集以一個(gè)字符串的形式保留:
復(fù)制代碼 代碼如下:
<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.close
conn.close
set rs = Nothingset conn = Nothing%></body>
</html>
| Constant 常量 |
Value 值 |
Description 描述 |
|---|---|---|
| adClipString | 2 | Delimits rows by the rowdel parameter, columns by the coldel parameter, and null values by the nullexpr parameter 指定rowdel參數(shù)對(duì)行(記錄)進(jìn)行界定;通過coldel參數(shù)對(duì)列(字段)進(jìn)行界定,通過nullexpr參數(shù)對(duì)空值進(jìn)行界定 |
相關(guān)文章
asp下用實(shí)現(xiàn)模板加載的的幾種方法總結(jié)
asp下html模板的加載方法,一般有以下幾種,大家可以根據(jù)情況自己決定,結(jié)果都是一樣的,都是好方法2008-01-01
簡(jiǎn)單的ASP中經(jīng)常用到的代碼[推薦]
簡(jiǎn)單的ASP中經(jīng)常用到的代碼[推薦]...2007-03-03
asp動(dòng)態(tài)include文件,方便多模板的實(shí)現(xiàn)
asp動(dòng)態(tài)include文件,方便多模板的實(shí)現(xiàn)...2007-08-08
asp長(zhǎng)文章用分頁(yè)符來(lái)分頁(yè)顯示
照正常的文章系統(tǒng)一路做下去,后臺(tái)的文章添加,文章的檢索,和文章的詳細(xì)頁(yè),都是常規(guī)方式操作,這里不加描述,請(qǐng)參閱相關(guān)帖子。2008-11-11
ASPWebPack(整站文件備份系統(tǒng)) v1.0.2 黑客也用
ASPWebPack(整站文件備份系統(tǒng)) v1.0.2 黑客也用...2007-10-10

