日期:2009-10-09 浏览次数:21218 次
function RecordSetAsArray(rsADO,includeHeaderRow)
function RecordSetAsDSO(rsADO)
//把ado.recordset中的数据放到一个表格中,返回这个表格的HTML代码
{
?var HTMLDSO = '';
?var nFields = rsADO.Fields.Count;
?if (nFields)
?{
??var n = 0;
??HTMLDSO += '<' + 'table>\n';???
??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>\n';???
???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();
??}
?}
?return rsArray;
}
function RecordAsObject(rsADO,objectName)
//以对象的方式返回ado.recordset中的一条记录
{
?if (typeof(objectName) == 'undefined')
??objectName = 'RSObject';
?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 < nFields; i++)
??{
???propName = rsADO(i).name;
???var c0 = propName.charAt(0);
???if ((propName.indexOf(' ') == -1) && ((c0 >= 'A' && c0 <= 'Z') || (c0 >= 'a' && c0 <= 'z')))
???{?// 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)
//把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>\n';???
??while (!rsAD