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