The RS. getstring method getstring is used to return the specified record set in the form of a string. You can use this method to add HTML tables to ASP files.
Getstring method syntax
Set STR = objrecordset. getstring (format, N, coldel, rowdel, nullexpr)
Parameter Parameters |
Description |
Format |
Optional. A stringformatenum value that specifies the format when retrieving A recordset as a string Optional. Specify |
N |
Optional. The number of rows to be converted in the recordset Recordsetstringformatenum value. It is used to specify the format for extracting Record Sets |
Coldel |
Optional. If format is set to adclipstring it is a column delimiter. Otherwise it is the Tab character Optional. If the format [format] value is set to adclipstring, It is a column delimiter. In addition, it is a tab [Tab]. |
Rowdel |
Optional. If format is set to adclipstring it is a row delimiter. Otherwise it is the carriage return character Optional. Optional. If the format [format] value is set to adclipstring, It is a line delimiter. In addition, it is a carriage return [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 Optional. Optional. If the format [format] value is set to adclipstring, it is an expression used to replace null values. In addition, it is an empty character. |
Case
To create an HTML table with data from A recordset, we only need to use three of the parameters above:
You only need to use one of the preceding three parameters to create an HTML record set data table:
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-use the line Separator in HTML Format
Nullexpr-the HTML to use if a column is null
Nullexpr-if the column is empty, use HTML
Note: The getstring () method is an ADO 2.0 feature.
In the following case, we will use the getstring () method to keep the record set as a string:
CopyCode The Code is as follows: <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 MERs", connstr = Rs. getstring (, "</TD> <TD>", "</TD> </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 constant |
value value |
description description |
adclipstring |
2 |
delimits rows by the rowdel parameter, columns by the coldel parameter, and null values by the nullexpr parameter specify the rowdel parameter to define the row (record; use the coldel parameter to define columns (fields) and the nullexpr parameter to define null values |