ASP ADO getRows() 使用演示 By shawl.qiu
说明:
本文演示了使用 ado getRows() 显示数据.
显示如:
QUOTE:
default by 0
4fields 4records
line: 0 field 0: 1 -|- field 1: IT术语 -|- field 2: 2006-5-12 -|- field 3: 20:46:16 -|- field 4: 1
line: 1 field 0: 2 -|- field 1: 词汇库 -|- field 2: 2006-5-16 -|- field 3: 13:23:00 -|- field 4: 888
line: 2 field 0: 3 -|- field 1: 政治术语 -|- field 2: 2006-5-16 -|- field 3: 17:36:11 -|- field 4: 60
line: 3 field 0: 4 -|- field 1: 纳天纳地 -|- field 2: 2006-5-16 -|- field 3: 17:50:52 -|- field 4: 999
line: 4 field 0: 5 -|- field 1: 商业术语 -|- field 2: 2006-5-25 -|- field 3: 18:37:11 -|- field 4: 20
shawl.qiu
2006-09-08
主内容:
linenum
<%
dim rs, ar, fldAr
fldAr=array("sbid","sbcat") '选取字段的数组
'fldAr=array("sbcat","sbid") '选取字段的数组
call fCreateRs(rs) '调用创建 recordset 函数
with rs
.open "select * from vT1",conn
'将数组值赋值给 ar 变量
''''''''''''''''''''''''''''''''''''''''''''''''''
'ar=.getRows(10,,fldAr) '(选取 10 条记录[空值选择全部记录],功能未知,选取字段的数组[空值选取全部字段])
ar=.getRows ' 将 getRows 取得的值赋给变量 ar
''''''''''''''''''''''''''''''''''''''''''''''''''
end with
call fCloseRs(rs) '调用关闭 recordset 函数
dim rsFld, rsTotal
rsFld=uBound(ar,1) ' 取表字段总数, 以 0 开始
rsTotal=Ubound(ar,2) ' 取表记录总数, 以 0 开始
response.write "default by 0<br/>"
response.write rsFld&"fields "&rsTotal&"records<p/>" '打印字段总数 和 记录总数
dim item, temp
For item=0 To rsTotal ' 循环输出所有记录
response.write "line: "
response.write item
response.write " "
for temp=0 to rsFld ' 循环输出所有字段的数据
Response.Write "field "
response.write temp
response.write ": "
response.write ar(temp,item) '(字段数字, 行数字)
if temp<rsFld then response.write " <font color=""red"">-|-</font> "
next 'shawl.qiu code'
response.write "<br/>"
Next
function fCreateRs(rs)
set rs=createObject("adodb.recordset")
end function
function fCloseRs(rs)
rs.close
set rs=nothing
end function
%>