ADOGetStringメソッド_
❮完全なレコードセットオブジェクトリファレンス
GetStringメソッドは、指定されたRecordsetを文字列として返します。このメソッドは、ASPファイルのHTMLテーブルに入力するために使用できます。
構文
Set str=objRecordset.GetString(format,n,coldel,rowdel,nullexpr)
Parameter | Description |
---|---|
format | Optional. A StringFormatEnum value that specifies the format when retrieving a Recordset as a string |
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 |
rowdel | Optional. If format is set to adClipString it is a row delimiter. Otherwise it is the carriage return character |
nullexpr | Optional. If format is set to adClipString it is an expression used instead of a null value. Otherwise it is an empty string |
例
レコードセットからのデータを使用してHTMLテーブルを作成するには、上記の3つのパラメーターのみを使用する必要があります。
- coldel-列区切り文字として使用するHTML
- rowdel-行区切り文字として使用するHTML
- NullExpr-列がNULLの場合に使用するHTML
注: GetString()メソッドはADO2.0の機能です。ADO 2.0は、 http://www.microsoft.com/data/download.htmからダウンロードできます。
例
次の例では、GetString()メソッドを使用して、レコードセットを文字列として保持します。
<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(,,"</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 = Nothing
set conn = Nothing
%>
</body>
</html>
StringFormatEnum値
Constant | Value | Description |
---|---|---|
adClipString | 2 | Delimits rows by the rowdel parameter, columns by the coldel parameter, and null values by the nullexpr parameter |
❮完全なレコードセットオブジェクトリファレンス