ADO Recordset 对象

Example

GetRows
This example demonstrates how to use the GetRows method.

Recordset object

The ADO Recordset object is used to contain a record set 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 operating on database data.

ProgID

set objRecordset=Server.CreateObject("ADODB.recordset")

When you first open a Recordset, the current record pointer points to the first record, and 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:

  • Immediate update - Once the Update method is called, all changes are immediately written to the database.
  • Batch update - The provider caches multiple changes and then transmits these changes to the database using the UpdateBatch method.

In ADO, 4 different cursor (pointer) types are defined:

  • Dynamic cursor - Allows you to view additions, changes, and deletions made by other users
  • Keyset cursor - Similar to dynamic cursor, but you cannot view additions made by other users, and it prevents you from accessing records deleted by other users. Changes to data made by other users are still visible.
  • Static cursor - Provides a static copy of the recordset that can be used to search for data or generate reports. In addition, additions, changes, and deletions made by other users will be invisible. This is the only cursor type allowed when opening a client Recordset object.
  • Forward-only cursor - Allows scrolling forward in the Recordset only. In addition, additions, changes, and deletions made by other users will be invisible.

The cursor type can be set through the CursorType property or the CursorType parameter in the Open method.

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

属性

属性 描述
AbsolutePage Set or return a value that can specify the page number of the Recordset object.
AbsolutePosition Set or return a value that can specify the order position (serial position) of the current record in the Recordset object.
ActiveCommand Return the Command object associated with the Recordset object.
ActiveConnection Set or return the definition of the connection if the connection is closed, or set or return the current Connection object if the connection is open.
BOF Return true if the current record position is before the first record, otherwise return false.
Bookmark Set or return a bookmark. This bookmark saves the position of the current record.
CacheSize Set or return the number of records that can be cached.
CursorLocation Set or return the location of the cursor service.
CursorType Set or return the cursor type of a Recordset object.
DataMember Set or return the name of the data member to be retrieved from the object referenced by the DataSource attribute.
DataSource Specify an object that contains the data to be represented as a Recordset object.
EditMode Return the editing status of the current record.
EOF Return true if the current record position is after the last record, otherwise return false.
Filter Return a filter for the data in the Recordset object.
Index Set or return the name of the current index of the Recordset object.
LockType Set or return a value that can specify the lock type when editing a record in the Recordset.
MarshalOptions Set or return a value that specifies which records are returned to the server.
MaxRecords Iset o ibalik ang maksimum na bilang ng mga tala na ibabalik mula sa isang paghahanap sa Recordset na bagay.
PageCount Ibalik ang bilang ng mga pahina ng data sa Recordset na bagay.
PageSize Iset o ibalik ang maksimum na bilang ng mga tala sa isang pahina ng Recordset na bagay.
RecordCount Ibalik ang bilang ng mga tala sa Recordset na bagay.
Sort Iset o ibalik ang pangalan ng isang o ilang mga patlang bilang batayan ng pagurangga ng Recordset.
Source Iset o ibalik ang isang string na halaga, o isang pagtutukoy ng Command na bagay, o ibalik ang isang string na halaga, na maaaring idikna ang pinagmulan ng data ng Recordset na bagay.
State Ibalik ang isang halaga, na maaaring ilarawan kung ang Recordset na bagay ay bukas, isara, naka-konekta, nagsasagawa o naka-retreive ng data.
Status Ibalik ang estado ng kasalukuyang tala sa batch update o iba pang malaking operasyon.
StayInSync Iset o ibalik kung ang pagbabago ng posisyon ng magulang na tala ay magiging pagbabago o hindi ang pagbabago ng sanggunian ng bata na tala.

Paraan

Paraan 描述
AddNew Lumikha ng isang bagong tala.
Cancel Bawiin ang isang pagpapatupad.
CancelBatch Bawiin ang isang batch update.
CancelUpdate Bawiin ang pagbabago sa isang tala ng Recordset na bagay.
Clone Lumikha ng isang kopya ng Recordset na mayroon.
Close Isara ang isang Recordset.
CompareBookmarks Hahambing ang dalawang bookmark.
Delete Alisin ang isang tala o isang grupo ng mga tala.
Find Hanapin ang isang tala sa Recordset na sumasang-ayon sa nakatakdang kondisyon.
GetRows Kopyahin ang ilang mga tala mula sa Recordset na bagay sa isang dalawang-dimensiyonal na array.
GetString Ibalik ang Recordset bilang string.
Move Ilipat ang pointer ng tala sa Recordset na bagay.
MoveFirst Ilipat ang pointer ng tala sa unang tala.
MoveLast Ilipat ang pointer ng tala sa huling tala.
MoveNext Ilipat ang pointer ng tala sa susunod na tala.
MovePrevious Ilipat ang pointer ng tala sa nakaraang tala.
NextRecordset Buksan sa pamamagitan ng pagpapatupad ng isang serye ng mga komando upang mawala ang kasalukuyang Recordset na bagay at ibabalik ang susunod na Recordset.
Open Buksan ang isang elemento ng database, na maaaring magbigay ng access sa mga tala ng table, mga resulta ng paghahanap o mga inilagay na Recordset.
Requery I-update ang data sa Recordset obyek sa pamamagitan ng muling pagpapatupad ng kweri na nakabase sa obyek.
Resync I-refresh ang data sa kasalukuyang Recordset mula sa orihinal na database.
Save I-save ang Recordset obyek sa file o Stream obyek.
Seek Maghanap sa index ng Recordset upang mabilis na mapansin ang linya na tumutugma sa tinukoy na halaga, at gawing kasalukuyang linya.
Supports Iibalik ang isang boolean na halaga, na maaring itakda kung ang Recordset obyek ay sumusuporta sa partikular na uri ng kakayahan.
Update I-save ang lahat ng pagbabago sa isang talaan ng Recordset obyek.
UpdateBatch I-save ang lahat ng pagbabago sa Recordset sa database. Gumamit ng batch update mode.

Kaganapan

Paalam: Hindi mo pwedeng hawakan ang mga kaganapan gamit ang VBScript o JScript (makakakuha lamang ng mga kaganapan ang mga wika ng Visual Basic, Visual C++, at Visual J++).

Kaganapan 描述
EndOfRecordset Ay nagbibigay ng utos kapag sinubukan na ilipat sa linya na higit sa katapusan ng Recordset.
FetchComplete Ay nagbibigay ng utos kapag lahat ng talaan ay nabasa sa asynchronous operation.
FetchProgress Ay nagbibigay ng utos sa panahon ng asynchronous operation, at ipinapakita kung gaano karaming talaan na nabasa.
FieldChangeComplete Ay nagbibigay ng utos pagkatapos nagbago ang halaga ng Field obyek.
MoveComplete Ay nagbibigay ng utos pagkatapos nagbago ang posisyon sa Recordset.
RecordChangeComplete Ay nagbibigay ng utos pagkatapos nagbago ang isang talaan.
RecordsetChangeComplete Ay nagbibigay ng utos pagkatapos nagbago ang Recordset.
WillChangeField Ay nagbibigay ng utos bago nagbago ang halaga ng Field obyek.
WillChangeRecord Ay nagbibigay ng utos bago nagbago ang isang talaan.
WillChangeRecordset Ay nagbibigay ng utos bago nagbago ang Recordset.
WillMove Ay nagbibigay ng utos bago nagbago ang posisyon sa Recordset.

Koleksyon

Koleksyon 描述
Fields Ipinapakita ang bilang ng Field obyek sa Recordset na ito.
Properties Nakakabahagi ng lahat ng Property obyek sa lahat ng Recordset obyek.

Fields 集合的属性

属性 描述
Count

返回 fields 集合中项目的数目。以 0 起始。

例子:

	countfields = rs.Fields.Count
	
Item(named_item/number)

返回 fields 集合中的某个指定的项目。

例子:

	itemfields = rs.Fields.Item(1)
	或者	
	itemfields = rs.Fields.Item("Name")
	

Properties 集合的属性

属性 描述
Count

返回 properties 集合中项目的数目。以 0 起始。

例子:

	countprop = rs.Properties.Count
	
Item(named_item/number)

返回 properties 集合中某个指定的项目。

例子:

	itemprop = rs.Properties.Item(1)
	或者
	itemprop = rs.Properties.Item("Name")