Object-oriented ASP programming four--some commonly used functions

Source: Internet
Author: User
function Recordsetasarray (Rsado,includeheaderrow)
Store the data in the Ado.recordset into an array
Generates a field header row when Includeheaderrow is true and does not occur when false
{
? var Rsarray = new Array;
? var nfields = RsADO.Fields.Count;
? if (Nfields)
? {
?? var n = 0;
?? if (Includeheaderrow)
?? {//include-a-row as header of field names
??? var rsrow = new Array (nfields);
??? for (Var i=0 i < Nfields; i++)
???? Rsrow[i] = Rsado (i). Name;
??? rsarray[n++] = Rsrow;
??}
??? if (!) ( RSADO.EOF&AMP;&AMP;RSADO.BOF))
????? Rsado.movefirst ()??
?? while (!rsado.eof)
?? {//Add each record to array
??? Rsrow = new Array (nfields);
??? for (Var i=0 i < Nfields; i++)
???? Rsrow[i] = Rsado (i). value;
??? rsarray[n++] = Rsrow;
??? Rsado.movenext ();
??}
?}
? return Rsarray;
}
function Recordsetasdso (Rsado)
Put the data in the Ado.recordset into a table and return the HTML code for the table.
{
? var htmldso = ';
? var nfields = RsADO.Fields.Count;
? if (Nfields)
? {
?? var n = 0;
?? Htmldso = ' < ' + ' table> ';???
?? while (!rsado.eof)
?? {//Add each record to table
??? Htmldso = ' < ' + ' tr> ';???
??? for (Var i=0 i < Nfields; i++)
??? {
???? Htmldso + = ' < ' + ' TD id= ' + Rsado (i). Name + ' > ' + rsado (i). Value + ' < ' + '/td> ';
???}
??? Htmldso = ' < ' + '/tr> ';???
??? Rsado.movenext ();
??}
?? Htmldso = ' < ' + '/table> ';???
?}
? return HTMLDSO;
}
function Recordsetaslist (Rsado,field)
Put data from a field in the Ado.recordset into an array
{
? var Rsarray = new Array;
? var nfields = RsADO.Fields.Count;
? if (Nfields)
? {
?? var n = 0;
?? if (!) ( RSADO.EOF&AMP;&AMP;RSADO.BOF))
????? Rsado.movefirst ()?
?? while (!rsado.eof)
?? {//Add each value of the field into array
??? rsarray[n++] = rsado (field). value;
??? Rsado.movenext ();
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.