方式2、
dim objRs
set objRs = Server.CreateObject( "ADODB.Recordset" )
objRs.open "table1" , objConn , 1 , 2
set objRs = Server.CreateObject( "ADODB.Recordset" )
objRs.open "table1" , objConn , 1 , 2
用这种方式打开的记录可以进行分页显示。
<%
dim objRs
set objRs = Server.CreateObject( "ADODB.Recordset" )
objRs.open "table1" , objConn , 1 , 2
objRs.pagesize = 5
objRs.absolutepage = 1
%>
dim objRs
set objRs = Server.CreateObject( "ADODB.Recordset" )
objRs.open "table1" , objConn , 1 , 2
objRs.pagesize = 5
objRs.absolutepage = 1
%>
用这个试试,哈哈,顺利运行。
但这种方式打开的记录集不能排序
文件test2.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="conn.asp" -->
<%
dim objRs
set objRs = Server.CreateObject( "ADODB.Recordset" )
objRs.open "table1" , objConn , 1 , 2
objRs.sort = "field1"
%>
<!-- #include file="conn.asp" -->
<%
dim objRs
set objRs = Server.CreateObject( "ADODB.Recordset" )
objRs.open "table1" , objConn , 1 , 2
objRs.sort = "field1"
%>
请求该页面得到的结果是:
--------------------------------------------------
错误类型:
ADODB.Recordset (0x800A0CB3)
当前提供程序不支持排序或过滤所必需的界面。
/msg/test2.asp, 第 17 行
浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
网页:
GET /msg/test2.asp
时间:
2005年9月21日, 20:17:32
--------------------------------------------------
怎办呢?
哈,这样就行啦。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="conn.asp" -->
<%
dim objRs
set objRs = Server.CreateObject( "ADODB.Recordset" )
objRs.CursorLocation = 3
objRs.open "table1" , objConn , 1 , 2
objRs.sort = "field1 desc"
%>
<!-- #include file="conn.asp" -->
<%
dim objRs
set objRs = Server.CreateObject( "ADODB.Recordset" )
objRs.CursorLocation = 3
objRs.open "table1" , objConn , 1 , 2
objRs.sort = "field1 desc"
%>
总结一下:
1、方式1,可以通过sql语句,方便地筛选你想要的记录。
2、方式2,功能比较强大,但比较复杂。
这种方式还有更有用的用法。详见其它参考资料。
