Recordset. asp

Source: Internet
Author: User

Recordset. asp

<%
Response. Buffer = true
Dim Conn
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "provider = sqloledb.1; Data Source = (local); User ID = sa; Password =; initial catalog = pubs"
Dim rs
Set rs = server. Createobject ("ADODB. recordset ")

'----- Recordset object method -----
'Cursor: adopenforwordonly: 0 adopenkeyset: 1 adopendynamic: 2 adopenstatic: 3
'0 can only be read one by one; 1 can be moved, movefirst, movelast; 2 and 3 can be used for all functions (such as recordcount ).
'Lock: adlockreadonly: 1 adlockpessimistic: 2 adlockoptimistic: 3 adlockbatchoptimistic: 4
'1 read-only, unable to run update, addnew, delete, etc.; 2 lock when data is updated to maintain data consistency; 3 can be synchronized by multiple users; 4 No.
'Options: adcmdunknow:-1 ad1_text: 1 adcmdtable: 2 ad1_storedproc: 3 (Note: ad1_storedproc: 4 in connection. Execute and command. Execute)
Rs. Open "select * from authors", Conn, 1, 2, 1
'Rs. Close
Rs. movefirst
Rs. movelast
Rs. movenext
Rs. moveprevious
'Move (numrecords, start) start value: 0 default, current record; 1 is based on the first record; 2 is based on the last record.
Rs. Move 5, 1
Rs. Update
Rs. cancelupdate
'Rs. addnew
'Rs. Delete
'Rs. requery
Set rs = Rs. Clone
Dim arr
Arr = Rs. getrows (5, "au_id ")
'----- Recordset object attribute -----
Rs. Close
Rs. activeconnection = Conn
'Rs. Source = cmd' recordset can be connected to the command object through the source attribute (source can be an SQL command, table, and stored procedure name)
Rs. cursortype = 1
Rs. locktype = 2
Rs. Open
Response. Write ("total records" & Rs. recordcount & "<p> ")
Response. Write ("Whether the cursor starts:" & Rs. bof & "<p> ")
Response. Write ("Whether the cursor ends:" & Rs. EOF & "<p> ")
Rs. Move 5
Rs. pagesize = 5
Response. Write ("page count:" & Rs. pagecount & "<p> ")
Response. Write ("the absolute number of pages of the current cursor in the recordset object:" & Rs. absolutepage & "<p> ")
Response. Write ("the position of the current cursor in the recordset object:" & Rs. absoluteposition & "<p> ")
'The bookmarks' utility instance allows you to quickly return records that have been bookmarked.
Dim book
Book = Rs. bookmark
Rs. Move 5
Rs. Bookmark = book
Rs. Filter = "au_lname = 'dull '"
Rs. Filter = ""
Response. Write ("Current dataset status:" & Rs. State) '1: Open 2: Closed
'Rs. cachesize = 10

'----- test statement -----
dim I
response. write ("


















") for I = 0 to Rs. fields. count-1 response. write (" ") next response. write (" ") do while not Rs. EOF response. write (" ") for I = 0 to Rs. fields. count-1 response. write (" ") next response. write (" ") Rs. movenext loop Rs. close set rs = nothing Conn. close set conn = nothing %>
" & RS (I ). name & "
" & RS (I) & "

Related Article

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.