ASP Rs.Open parameter 1,2,3 detailed

Source: Internet
Author: User

Read the data with Rs.Open sql,conn,1,1
Modifying data: Rs.Open sql,conn,1,3
Delete data: Directly to Conn.execute ("Delete * from new where id=1").

The Rs.Open syntax is as follows: Rs.Open Source,activeconnection,cursortype,locktype

Source is a SQL statement, ActiveConnection is a database tutorial connection, CursorType is a cursor, and LockType is a data locking type.

CursorType

Constants Description
adOpenForwardOnly (value 0) (the default) opens a forward-only type cursor.
adOpenKeyset (value 1) Opens the keyset type cursor.
adOpenDynamic (value 2) opens a dynamic type cursor.
adOpenStatic (value 3) opens a static type cursor.


LockType


Constants Description
adLockReadOnly (value 1) (default) read-only-cannot change data.
adLockPessimistic (value 2) pessimistic locking (one by one)-the provider completes the work necessary to ensure that records are successfully edited, typically by locking the record of the data source as soon as it is edited.
adLockOptimistic (value 3) Open lock (one by one)-the provider uses optimistic locking, which locks records only when the Update method is invoked.
adLockBatchOptimistic (value 4) Open batch update-for batch update mode (as opposed to immediate update mode).

CursorType
0 is a forward-only cursor, can only be browsed forward, does not support paging, Recordset, bookmark
1-keyset cursors, and other users ' modifications to records are reflected in the recordset, but additional users adding or deleting records are not reflected in the recordset. Support for paging, Recordset, bookmark
2 Dynamic cursors are the most powerful, but also the most expensive sources. User changes to the record, add or delete records will be reflected in the recordset. Support full feature browsing.
3 static cursors, just a snapshot of the data, changes that the user makes to the record, adding or deleting records are not reflected in the recordset. Supports moving forward or backward

The

LockType
LockType is the lock type of the recordset, with the value:
1 lock type, default, read-only, no modification
2 when editing the record immediately, the safest way
3 locks the recordset only when the Update method is invoked. While other previous operations can still make changes to the current record, insert and delete the
4 when editing the record will not be locked, and change, insert and delete
Rs.Open sql,conn,3,2
These two are cursors, the specific effect is:
Rs.Open sql, Conn,a,b
A:
adOpenForwardOnly (=0)
Read only, and the current data record can only be moved down
adOpenKeyset (=1)
Read-only, the current data record is free to move
Adopendyn Amic (=2)
Read-write, current data record free to move
adOpenStatic (=3)
Read-write, current data record free to move, see new record
B:
adLockReadOnly (=1)
Default lock Type, the recordset is read-only, the record
adLockPessimistic (=2)
Pessimistic lock cannot be modified, and when a record is modified, the data provider attempts to lock the record to ensure that it is successfully edited. Lock the record immediately as soon as the editor starts.
adLockOptimistic (=3)
optimistic locking, until the record is locked when the update record is submitted with the Update method.
adLockBatchOptimistic (=4)
Bulk optimistic locking allows you to modify multiple records, and only the UpdateBatch method is invoked before the record is locked.
When you do not need to change any records, you should use a read-only recordset, so that the provider does not have to do any testing.
For general use, optimistic locking may be the best option because records are locked for a short period of time, and
data is updated during that time. This reduces the use of resources.
Summary:
The sql,conn,1,1 representative does not allow updates and is generally used for query operations. The
sql,conn,1,3 representative allows updates, typically for inserts, updates, and deletes.

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.