指引网

当前位置: 主页 > 编程开发 > ASP >

面向对象的asp编程之四--一些常用的函数

来源:网络 作者:佚名 点击: 时间:2017-06-22 20:41
[摘要] function RecordSetAsArray(rsADO,includeHeaderRow) //把ado.recordset中的数据存放到一个数组里 //当includeHeaderRow为真时产生字段标题行,当为假时不产生 { ?var rsArray = new Array; ?var nFields = rsADO.Fields.Cou
function RecordSetAsArray(rsADO,includeHeaderRow)
//把ado.recordset中的数据存放到一个数组里
//当includeHeaderRow为真时产生字段标题行,当为假时不产生
{
?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 < nFields; 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 < nFields; i++)
????rsRow[i] = rsADO(i).value;
???rsArray[n++] = rsRow;
???rsADO.MoveNext();
??}
?}
?return rsArray;
}
function RecordSetAsDSO(rsADO)
//把ado.recordset中的数据放到一个表格中,返回这个表格的html代码
{
?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)
//把ado.recordset中的某个字段的数据放到数组中
{
?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();
------分隔线----------------------------