一聚教程网:一个值得你收藏的教程网站

热门教程

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

时间:2022-06-30 11:25:16 编辑:袖梨 来源:一聚教程网

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();

热门栏目