Adodb.recordset.open (Rs.Open) method parameter detailed _asp Foundation

Source: Internet
Author: User

ADO Recordset Object

The ADO Recordset object is used to hold a recordset from a database table. A Recordset object consists of records and columns (fields).

In ADO, this object is the most important and most commonly used object for manipulating data from a database.

ProgID

Set Objrecordset=server.createobject ("Adodb.recordset")

When you first open a recordset, the current record pointer points to the first record, while the BOF and EOF properties are False. If there are no records, the BOF and EOF properties are True.

The Recordset object can support two types of updates:

Update now-all changes are immediately written to the database once the Update method is called. Batch update-provider will cache multiple changes and then use the UpdateBatch method to transfer those changes to the database.
In ADO, different cursor (pointer) types are defined in 4:

• Dynamic cursors-Allows you to view additions, changes, and deletions made by other users
• Keyset cursors-Similar to dynamic cursors, where you cannot view additions made by other users, and it prevents you from accessing records that other users have deleted. Data changes made by other users are still visible.
• Static cursors-Provides a static copy of a recordset that can be used to find data or generate reports. In addition, additions, changes, and deletions made by other users will be invisible. This is the only allowed cursor type when you open a client-side Recordset object.
• Forward-only cursors-only allow scrolling forward in the Recordset. In addition, additions, changes, and deletions made by other users will be invisible.
You can set the type of the cursor through the CursorType property or the CursorType parameter in the Open method.

Note: Not all the providers (providers) support all the methods and properties of the Recordset object.

Friends who want to learn more about the ADO Recordset object can come here to see more.

If reading alone does not involve an update operation, then use the 1,1
If a read and update operation is involved, you can use 1,3 or 3,2

The Open method prototype for the Recordset object:
Open ([source],[activeconnection],[cursortype],[locktype],[options])
CursorType Cursor Type:
Const adopenforwardonly = 0
Forward cursors, which provide the fastest running performance for the default cursors. Use it to open the recordset and get all the results from the order to the end. It does not support scrolling backwards, only allowing one-way movement between results.

Const adOpenKeyset = 1
A static cursor that reflects the state of the data in the table the first time the cursor was opened, and the cursor was unable to find out whether the rows in the underlying table had been updated, deleted, or added new data. However, unlike a continent that can only be moved forward, a static cursor can scroll back and forth between results.

Const adopendynamic = 2
A keyboard-driven cursor that can query some of the underlying data rows in a table, but not all of them. In particular, it can accurately reflect whether the data has been updated. However, it does not find out whether other users have deleted rows of data (deleted rows of data leave holes in the recordset). Keyboard-driven Cursors support scrolling back and forth between results.

Const adOpenStatic = 3
Dynamic cursors, which are the richest types of cursors. When the cursor is open, you can query any other user for any changes to the table and support scrolling.

LockType Lock Type:
Const adLockReadOnly = 1
The default lock type, read-only lock allows multiple users to read the same data at the same time, but cannot change the data.

Const adlockpessimistic = 2
Open the data object in pessimistic lock mode. This assumes that you will have other users accessing the data when you edit the record. Once you start editing the record, other users will not be able to access the data.

Const adLockOptimistic = 3
Open the data object in optimistic lock mode. This assumes that no other user will be able to access the data while you are editing the record. The record cannot be accessed by other users until the change is completed.

Const adLockBatchOptimistic = 4
Use this type when performing multiple-line batch update

Options parameter:
The options parameter indicates the type of command string used to open the recordset. Tell Ado about information about the string content being executed to help execute the command string efficiently.

adCmdTable. The string being executed contains the name of a table.
adCmdText. The string being executed contains a command text.
adCmdStoredProc. The string being executed contains a stored procedure name.
adCmdUnknown. Does not specify the contents of the string. (This is the default value.) )

The simple point is:

Rs. OPEN sql,conn,a,b
A:adopenforwardonly (=0) is read-only and the current data record can only be moved down
adOpenStatic (=3) is read-only and the current data record is free to move
adOpenKeyset (=1) can read and write, the current data record can be moved freely
adOpenDynamic (=2) can read and write, the current data record can be moved freely, you can see the new record

B:adlockreadonly (=1) default value for opening read-only records
adLockPessimistic (=2) pessimistic lock
adLockOptimistic (=3) optimistic lock
adLockBatchOptimistic (=4) batch optimistic lock

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.