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