当前位置:编程学习 > asp >>

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

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();
补充:asp教程,脚本编码
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,