Comparison of several methods for opening record sets

Source: Internet
Author: User
Comparison of several methods for opening record sets
Define conn. asp first
<%
Dim objConn
Dim strConn
StrConn = "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" & chr (34) & Server. MapPath ("data. mdb") & chr (34)
Set objConn = server. createobject ("adodb. connection ")
ObjConn. open strConn
%>
Let's take a look at several different recordset methods.
Method 1,
Dim SQL
Dim objRs
SQL = "select * from table1"
Set objRs = objConn.exe cute (SQL)
In this way, you can obtain the record set after executing the SQL statement, and obtain the filtered record set,
However, the record set obtained in this way cannot be displayed by page.
File text1.asp
<% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "936" %>
<! -- # Include file = "conn. asp" -->
<%
Dim SQL
Dim objRs
 
SQL = "select * from table1"
Set objRs = objConn.exe cute (SQL)
 
ObjRs. pagesize = 5
ObjRs. absolutepage = 1
%>
The result of a request to this page is:
------------------------------------------------------------
Error Type:
ADODB. Recordset (0x800A0CB3)
The current record set does not support bookmarks. This may be a restriction on the provider or the selected cursor type.
/Msg/test1.asp, row 12th
Browser type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;. net clr 1.1.4322)
Webpage:
GET/msg/test1.asp
Time:
September 21, 2005 19:58:01
------------------------------------------------------------
Method 2,
Dim objRs
Set objRs = Server. CreateObject ("ADODB. Recordset ")
ObjRs. open "table1", objConn, 1, 2
Records opened in this way can be displayed by page.
<%
Dim objRs
 
Set objRs = Server. CreateObject ("ADODB. Recordset ")
ObjRs. open "table1", objConn, 1, 2
 
ObjRs. pagesize = 5
ObjRs. absolutepage = 1
%>
Use this to try and run smoothly.
However, records opened in this way cannot be sorted.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.