Function recordsetasarray (rsado, includeheaderrow)
// Store the data in ADO. recordset to an array.
// When includeheaderrow is true, the field title line is generated. If it is false, no field title line is generated.
{
? VaR rsarray = new array;
? VaR nfields = rsado. Fields. count;
? If (nfields)
? {
?? VaR n = 0;
?? If (includeheaderrow)
?? {? // Include first row as header of Field Names
??? VaR rsrow = new array (nfields );
??? For (VAR I = 0; I ???? Rsrow [I] = rsado (I). Name;
??? Rsarray [n ++] = rsrow;
??}
??? If (! (Rsado. EOF & rsado. bof ))
????? Rsado. movefirst ()??
?? While (! Rsado. EOF)
?? {? // Add each record to array
??? Rsrow = new array (nfields );
??? For (VAR I = 0; I ???? Rsrow [I] = rsado (I). value;
??? Rsarray [n ++] = rsrow;
??? Rsado. movenext ();
??}
?}
? Return rsarray;
}
Function recordsetasdso (rsado)
// Put the data in ADO. recordset into a table and return the HTML code of the table.
{
? VaR htmldso = '';
? VaR nfields = rsado. Fields. count;
? If (nfields)
? {
?? VaR n = 0;
?? Htmldso + = '/N ';???
?? While (! Rsado. EOF)
?? {? // Add each record to table
??? Htmldso + = '';???
??? For (VAR I = 0; I ??? {
???? Htmldso + = ''+ rsado (I). Value + '';
???}
??? Htmldso + = '/N ';???
??? Rsado. movenext ();
??}
?? Htmldso + = '';???
?}
? Return htmldso;
}
Function recordsetaslist (rsado, field)
// Put the data of a field in ADO. recordset into the Array
{
? VaR rsarray = new array;
? VaR nfields = rsado. Fields. count;
? If (nfields)
? {
?? VaR n = 0;
?? If (! (Rsado. EOF & rsado. bof ))
????? Rsado. movefirst ()?
?? While (! Rsado. EOF)
?? {? // Add each value of field into Array
??? Rsarray [n ++] = rsado (field). value;
??? Rsado. movenext ();
??}
?}
? Return rsarray;
}
Function recordasobject (rsado, objectname)
// Return a record in ADO. recordset as an object
{
? If (typeof (objectname) = 'undefined ')
?? Objectname = 'rsobobject ';
? VaR strobject = 'function' + objectname + '(){';
? VaR nfields = rsado. Fields. count;
? If (! Rsado. EOF)
? {
?? VaR value = new string;
?? VaR propname = new string;
?? For (VAR I = 0; I ?? {
??? Propname = rsado (I). Name;
??? VaR C0 = propname. charat (0 );
??? If (propname. indexof ('') =-1) & (C0> = 'A' & C0 = 'A' & C0 ??? {? // Exclude fields that are invalid variable names
???? Value = rsado (I). value;
???? If (isnan (parsefloat (value )))
????? Strobject + = 'this. '+ propname +' = "'+ value + '";';
???? Else
????? Strobject + = 'this. '+ propname +' = '+ value + ';';
???}
??}
?}
? Strobject + = '}';
? Eval (strobject );
? Return eval ('new' + objectname );
}
Function recordsetasarray (rsado, includeheaderrow)
// Store the data in ADO. recordset to an array.
// When includeheaderrow is true, the field title line is generated. If it is false, no field title line is generated.
{
? VaR rsarray = new array;
? VaR nfields = rsado. Fields. count;
? If (nfields)
? {
?? VaR n = 0;
?? If (includeheaderrow)
?? {? // Include first row as header of Field Names
??? VaR rsrow = new array (nfields );
??? For (VAR I = 0; I ???? Rsrow [I] = rsado (I). Name;
??? Rsarray [n ++] = rsrow;
??}
??? If (! (Rsado. EOF & rsado. bof ))
????? Rsado. movefirst ()??
?? While (! Rsado. EOF)
?? {? // Add each record to array
??? Rsrow = new array (nfields );
??? For (VAR I = 0; I ???? Rsrow [I] = rsado (I). value;
??? Rsarray [n ++] = rsrow;
??? Rsado. movenext ();
??}
?}
? Return rsarray;
}
Function recordsetasdso (rsado)
// Put the data in ADO. recordset into a table and return the HTML code of the table.
{
? VaR htmldso = '';
? VaR nfields = rsado. Fields. count;
? If (nfields)
? {
?? VaR n = 0;
?? Htmldso + = '/N ';???
?? While (! Rsado. EOF)
?? {? // Add each record to table
??? Htmldso + = '';???
??? For (VAR I = 0; I ??? {
???? Htmldso + = ''+ rsado (I). Value + '';
???}
??? Htmldso + = '/N ';???
??? Rsado. movenext ();
??}
?? Htmldso + = '';???
?}
? Return htmldso;
}
Function recordsetaslist (rsado, field)
// Put the data of a field in ADO. recordset into the Array
{
? VaR rsarray = new array;
? VaR nfields = rsado. Fields. count;
? If (nfields)
? {
?? VaR n = 0;
?? If (! (Rsado. EOF & rsado. bof ))
????? Rsado. movefirst ()?
?? While (! Rsado. EOF)
?? {? // Add each value of field into Array
??? Rsarray [n ++] = rsado (field). value;
??? Rsado. movenext ();
??}
?}
? Return rsarray;
}
Function recordasobject (rsado, objectname)
// Return a record in ADO. recordset as an object
{
? If (typeof (objectname) = 'undefined ')
?? Objectname = 'rsobobject ';
? VaR strobject = 'function' + objectname + '(){';
? VaR nfields = rsado. Fields. count;
? If (! Rsado. EOF)
? {
?? VaR value = new string;
?? VaR propname = new string;
?? For (VAR I = 0; I ?? {
??? Propname = rsado (I). Name;
??? VaR C0 = propname. charat (0 );
??? If (propname. indexof ('') =-1) & (C0> = 'A' & C0 = 'A' & C0 ??? {? // Exclude fields that are invalid variable names
???? Value = rsado (I). value;
???? If (isnan (parsefloat (value )))
????? Strobject + = 'this. '+ propname +' = "'+ value + '";';
???? Else
????? Strobject + = 'this. '+ propname +' = '+ value + ';';
???}
??}
?}
? Strobject + = '}';
? Eval (strobject );
? Return eval ('new' + objectname );
}
?
Note: Some of these functions are derived from Microsoft scripting library in Microsoft InterDev.