ADO GetString- metode


❮ Voltooi rekordstel-objekverwysing

Die GetString-metode gee die gespesifiseerde rekordstel as 'n string terug. Hierdie metode kan gebruik word om HTML-tabelle in ASP-lêers te vul.

Sintaksis

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

Voorbeeld

Om 'n HTML-tabel met data van 'n rekordstel te skep, hoef ons net drie van die parameters hierbo te gebruik:

  • Coldel - die HTML om as 'n kolomskeider te gebruik
  • rowdel - die HTML om as 'n ry-skeier te gebruik
  • NullExpr - die HTML om te gebruik as 'n kolom NULL is

Let wel: Die GetString()-metode is 'n ADO 2.0-kenmerk. Jy kan ADO 2.0 aflaai by http://www.microsoft.com/data/download.htm .

Voorbeeld

In die volgende voorbeeld sal ons die GetString() metode gebruik om die rekordstel as 'n string te hou:

<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>","&nbsp;")
%>

<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-waardes

Constant Value Description
adClipString 2 Delimits rows by the rowdel parameter, columns by the coldel parameter, and null values by the nullexpr parameter

❮ Voltooi rekordstel-objekverwysing