通过正常提取:
复制代码 代码如下:
<%
Set conn= Server.CreateObject("ADODB.Connection")
c&Server.MapPath("db2.mdb")
conn.Open connstr
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from people order by id desc"
rs.Open sql,conn,1,1
Do While Not rs.EOF
Response.write rs("id")&" | "
rs.MoveNext
Loop
%>
http://www.cnbruce.com/test/getrows/show1.asp
耗时3,250.000毫秒,总测试平均值在3秒左右
==========================================================
使用存储过程提取:
复制代码 代码如下:
<%
Set conn = Server.CreateObject("ADODB.Connection")
Set cmd = Server.CreateObject("ADODB.Command")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db2.mdb")
cmd.ActiveConnection = conn
cmd.CommandText = "Select * from people order by id desc"
Set rs = cmd.Execute
Do While Not rs.EOF
Response.write rs("id")&" | "
rs.MoveNext
Loop
%>
http://www.cnbruce.com/test/getrows/show2.asp
耗时2,187.500毫秒,总测试平均值在2秒左右
=========================================================
以上两种均不能彻底解决执行时间漫长的问题,主要原因即是循环每次都须向数据库抽取记录(Command速度相对较快)
那么使用GetRows()方法呢:
复制代码 代码如下:
<%
Set conn = Server.CreateObject("ADODB.Connection")
Set cmd = Server.CreateObject("ADODB.Command")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db2.mdb")
cmd.ActiveConnection = conn
cmd.CommandText = "Select * from people order by id desc"
Set rs = cmd.Execute
rsArray = rs.GetRows()
For i = 0 To UBound(rsArray, 2)
Response.Write rsArray(0, i)&" | "
Next
%>
http://www.cnbruce.com/test/getrows/show3.asp