ADO GetString 메서드
❮ 완전한 레코드세트 개체 참조
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 테이블을 생성하려면 위의 세 가지 매개변수만 사용하면 됩니다.
- Coldel - 열 구분 기호로 사용할 HTML
- rowdel - 행 구분 기호로 사용할 HTML
- NullExpr - 열이 NULL인 경우 사용할 HTML
참고: GetString() 메서드는 ADO 2.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 |
❮ 완전한 레코드세트 개체 참조