Read data using RS. Open SQL, Conn

Source: Internet
Author: User

Rs. Open SQL, Conn, are used to read data.

Modify data: Rs. Open SQL, Conn, 1, 3

Delete data: You can directly delete data such as conn.exe cute ("delete * From New where id = 1.

Rs. Open Syntax: Rs. Open source, activeconnection, cursortype, locktype

Source is an SQL statement, activeconnection is a database tutorial connection, cursortype is a cursor, locktype is a data lock type.

Cursortype

Constant description

Adopenforwardonly (value: 0) (default value) open only forward type cursor.

Adopenkeyset (value: 1) opens the keyset type cursor.

Adopendynamic (value: 2) opens the dynamic type cursor.

Adopenstatic (value: 3) open a static type cursor.

Locktype

Constant description

Adlockreadonly (value: 1) (default value) read-only-data cannot be changed.

Adlockpessimistic (value: 2) Locking (one by one)-The provider completes the work required to ensure successful record editing, usually by locking the records of the data source at the time of editing.

Adlockoptimistic (value: 3) open locks (one by one)-The provider uses open locks to lock records only when the update method is called.

Adlockbatchoptimistic (value: 4) Open batch Update-used in batch update mode (relative to the immediate update mode ).

Cursortype

0: Only forward cursor. Only forward browsing records are supported. pagination, recordset, and bookmark are not supported.

1. keyset cursor. The changes made by other users to the record will be reflected in the record set, but the addition or deletion of records by other users will not be reflected in the record set. Supports paging, recordset, and bookmark

2. dynamic cursors are the most powerful, but consume the most resources. The added or deleted records modified by the user on the record description will be reflected in the record set. Supports full-featured browsing.

3. The static cursor is only a snapshot of the data. The changes, additions, or deletions to the record statement by the user will not be reflected in the record set. Supports moving forward or backward

Locktype

Locktype is the lock type of the record set. Its value is:

1. Lock type. The default value is read-only and cannot be modified.

2. Lock the record immediately when editing. The safest way is

3. the record set is locked only when the update method is called. Other operations can still modify, insert, or delete the current record.

4. The record will not be locked during editing, but will be changed, inserted, or deleted.

Rs. Open SQL, Conn, 3, 2

The two are cursors. The specific functions are as follows:

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 records can be freely moved

Adopendynamic (= 2)

Read/write: The current data records can be freely moved.

Adopenstatic (= 3)

Read/write: The current data record can be freely moved. You can see the new record.

B:

Adlockreadonly (= 1)

Default lock type. The record set is read-only and cannot be modified.

Adlockpessimistic (= 2)

Pessimistic locking: When a record is modified, the data provider attempts to lock the record to ensure that the record is edited successfully. You only need to edit the record at the beginning, and lock the record immediately.

Adlockoptimistic (= 3)

Optimistic Locking: The record is locked only when an update record is submitted using the update method.

Adlockbatchoptimistic (= 4)

Optimistic Locking in batches. Multiple records can be modified. Records are locked only after the updatebatch method is called.

When no record needs to be modified, the read-only record set should be used, so that the provider does not need to perform any detection.

For general use, Optimistic Locking may be the best option, because the record is locked for only a short period of time,

The data is updated during this period. This reduces resource usage.

Summary:

SQL, Conn, indicates that updates are not allowed and are generally used for query operations.

SQL, Conn, 1, 3 indicates that update is allowed. It is generally used for insert, update, and delete operations.

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.