ADO today about the properties of the Recordset object
1, CursorType Property
adOpenForwardOnly: Forward-only cursors, default values. In addition to scrolling forward only in records, it is the same as a static cursor. Use it to improve performance when you only need to move one way in a recordset. (as the name suggests, this cursor can only move forward.) However, because of its limited functionality, this cursor is useful for system resources. )
adOpenKeyset: Keyset cursor. Although you cannot access records deleted by other users from your recordset, the keyset cursor is similar to a dynamic cursor, except that you cannot view the records added by other users. You can still see the data that other users have changed. (The keyset cursor allows you to see changes made by other users since it was created, but you cannot see records added or deleted by other users.) )
adOpenDynamic: Dynamic cursors. You can see additions, changes, and deletions made by other users. Allows all types of movement in a recordset, but does not include bookmark operations that are not supported by the provider. (This type of cursor is powerful and also consumes the most system resources.) Dynamic cursors can see all the changes they have saved the collection of records. Users with dynamic cursors can see edits, additions, and deletions made by other users. If the data provider allows this type of cursor, it supports this visibility by fetching data from the data source every once in a while. There is no doubt that this will require a lot of resources. )
adOpenStatic: Static cursor. A static copy of a collection of records that can be used to find data or generate reports. In addition, additions, changes, or deletions made to other users are not visible. (A static class cursor is just a snapshot of the data.) This means that it cannot see the changes that other users have made to the recordset since it was created. With this type of cursor you can sail forward and backward. Because of its simple function, the demand for resources is smaller than dynamic! )
Note that once you open the recordset, you cannot change the CursorType property. However, if you first close the recordset, change the CursorType property, and then reopen the recordset, you can still effectively change the cursor type!
2, LockType Property
In any database application that can be modified by multiple users at the same time, you must handle the situation where multiple users may be working on the same record at the same time. When this happens, the integrity of the data is compromised because a user may inadvertently overwrite other people's changes while saving his or her changes. Then you'll feel like you're not doing anything at all. In order to deal with this situation. ADO allows you to determine the type of concurrency event control when you update a Recordset object, and how to lock the record when a user edits it. This is determined by the LockType attribute. This property has four values:
adLockReadOnly: Default value, Read only. Unable to change data. (This is the default value for Recodset, and if you set the lock to that value, you will not be able to update the Recordset.) )
adLockPessimistic: Conservative record-locking (article by article). The provider performs the necessary actions to ensure that the record is successfully edited, typically by locking the record of the data source immediately when editing. (If set to this type of lock, the record is locked and can only be accessed by a user who edits when the edit starts to the time that the record is submitted to the data provider)! )
adLockOptimistic: Open Record Lock (article by article). The provider uses optimistic locking to lock records only when the Update method is invoked. (The record is locked only at the moment when the data is submitted to the data provider.) )
adLockBatchOptimistic: Open batch update. Batch update mode to reverse the immediate update mode. (set to this type of locking format will be called a recordset for batch update mode.) You can speed up updating the recordset to modify the data, but it also worsens problems associated with concurrent access because it updates multiple records at the same time! )
3, AbsolutePage Property
The AbsolutePage property sets the number of page numbers where the current record is located, and the PageSize property to divide the Recordset object into logical pages, with a record number of pagesize per page (except that the last page may have fewer than pagesize records )。 It must be noted that not all data providers support this attribute, so be careful when using it.
As with the AbsolutePosition property, the AbsolutePage property starts with 1, and if the current record is the first row of the recordset, the AbsolutePage is 1. You can set the AbsolutePage property to move to the first row record position on a specified page.
4, AbsolutePosition property
If you need to determine where the current metrics are in the recordset, you can use the AbsolutePosition property.
The value of the AbsolutePosition attribute is the current index relative to the position of the first pen, from 1, that is, the first absoluteposition is 1.
Note that when you access the recordset, you cannot guarantee that the recordset will appear in the same order each time.
To enable AbsolutePosition, you must first set up to use the user-side cursor (pointer): Rs. Cursorlocation=3
5, PageCount Property
Use the PageCount property to determine how many "pages" of data the Recordset object includes. Here the "page" is a collection of data records, the size is equal to the setting of the PageSize property, even if the last page records less than the PageSize value, the last page is a PageCount page. It is important to note that not all data providers support this property.
6, PageSize Property
The PageSize property is the key to determining how ADO is paged when it accesses a database, using it to determine how many records make up a logically "one page". Sets and builds the size of a page to allow the use of the AbsolutePage property to move to the first record of another logical page. PageSize properties can be set at any time.
7, RecordCount property
This is also a very common and important attribute, and we often use the RecordCount property to find out how many records a Recordset object includes. Use the RecordCount property to determine the number of records in a Recordset object. When ADO cannot determine the number of records, or if the provider or cursor type does not support RecordCount, this property returns –1. Reading the RecordCount property on a closed Recordset will result in an error. The cursor type of the Recordset object affects whether the number of records can be determined. For forward-only cursors, the RecordCount property returns-1, which returns the actual count for the static or keyset cursor, depending on the data source return-1 or the actual count for the dynamic cursor.
8, BOF and EOF properties
Typically, we write code in an ASP program to verify the BOF and EOF attributes, thus knowing the location of the recordset pointed to by the current indicator, using the BOF and EOF attributes, You can tell whether a Recordset object contains records or whether the move record row has gone beyond the Recordset object's scope.
If the current record is positioned before the first row of a Recordset object, the BOF property returns True, and vice versa returns false.
If the current record is positioned after the last row of a Recordset object, the EOF property returns True and vice versa.
(both BOF and EOF are true to indicate that there are no records in the recordset.) )
9. Filter Properties
Specifies the filter criteria for the data in the recordset, using the Filter property to selectively mask the records in the Recordset object, and the filtered recordset becomes the current cursor.
This affects other properties that are based on the current cursor return value, such as AbsolutePosition, AbsolutePage, RecordCount, and PageCount, because the Filter property is set to a special
A fixed value moves the current record to the first record that satisfies the new value.
This attribute I think is quite useful, sometimes we open the recordset for some judgment after we want to filter the record is to readjust the SQL statement, we closed the recordset and then opened with a new SQL statement? No, we filter with the Filter property, for example
Rs.Open exec,conn,1,1
If ... then rs.filter= "name= ' xxx"
Instead of
Rs.Open exec,conn,1,1
If ... then
Rs.close
exec=exec& "where name= ' xxx '"
Rs.Open exec,conn,1,1
End If
In fact, many places have to use filter, in the future of ASP skills will be said, we can also think about.
Go ahead and talk about the method of the Recordset object tomorrow.