Latest web development tutorials

ADO Recordset object

Examples

GetRows
This example demonstrates how to use the GetRows method.


Recordset object

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

In ADO, this object is the most important and most frequently used data in the database objects to operate.

ProgID

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

When you first open a Recordset, the current record pointer will point to the first record, and BOF and EOF property is False. If there are no records, BOF and EOF property to True.

Recordset objects can support two types of updates:

    Update - once you call the Update method, all changes are immediately written to the database. Batch Update - provider caches multiple changes, and then use the UpdateBatch method to transfer the changes to the database.

In ADO, we define four different cursor (pointer) type:

  • Dynamic cursor - Allows you to see other users add, change and delete
  • Keyset cursor - similar dynamic cursor, except that you can not see other users that you have added, and it will prevent you from accessing another user deleted records. Data changes made by other users are still visible.
  • Static cursor - Provides a static copy of a record set can be used to find data or generate reports. In addition, adding made by other users, change, and delete will not be visible. When you open a client-side Recordset object, which is the only type of cursor allowed.
  • Forward only cursors - allow only scroll forward through the Recordset. In addition, adding made by other users, change, and delete will not be visible.

Cursor type can be set via the CursorType property or Open method CursorType parameter.

Note: Not all providers (providers) support Recordset object's methods and properties.


Attributes

Attributes description
AbsolutePage Sets or returns a value specified Recordset object page number.
AbsolutePosition Sets or returns a value that can be specified ordinal position (ordinal position) Recordset object's current record.
ActiveCommand Returns Recordset object associated Command objects.
ActiveConnection If the connection is turned off, or return to define the connection, if the connection is open, sets or returns the current Connection object.
BOF If the current record position is before the first record, it returns true, otherwise fasle.
Bookmark Sets or returns a bookmark. Bookmark this location to save the current record.
CacheSize Sets or returns the number of records that can be cached.
CursorLocation Sets or returns the position of the cursor service.
CursorType Sets or returns the cursor type of a Recordset object.
DataMember Sets or returns the name of the object from the referenced DataSource property retrieved data member.
DataSource Specifies a file containing the object to be represented as a Recordset object's data.
EditMode Back to editing status of the current record.
EOF If the current record after the last record, it returns true, otherwise fasle.
Filter Returns a Recordset object for the data filter.
Index Sets or returns the name of the current Recordset object index.
LockType Sets or returns Recordset when editing a record, the value of the specified type lock.
MarshalOptions Sets or returns a value that specifies which records are returned to the server.
MaxRecords Sets or returns a query that returns a Recordset object from the maximum number of records.
PageCount Returns a Recordset object data pages.
PageSize Sets or returns the maximum number of records on a single page Recordset object allows.
RecordCount Returns the number of records in a Recordset object.
Sort Sets or returns one or more reference as Recordset sort field names.
Source Setting a string value, or a Command object reference, or returns a string value that may indicate the data source Recordset object.
State It returns a value that can describe whether the Recordset object is open, closed, connecting, in progress or retrieve data.
Status Back batch updates or other bulk operations related to the status of the current record.
StayInSync Sets or returns when the pair recorded when the parent record position changes reference is changed.

method

method description
AddNew Create a new record.
Cancel Undo the last execution.
CancelBatch Undo the last batch update.
CancelUpdate Withdrawal of a record in the Recordset object changes.
Clone Create a copy of an existing Recordset.
Close Closing a Recordset.
CompareBookmarks Compares two bookmarks.
Delete Delete a record or group of records.
Find Search a Recordset that satisfies a condition specified in a record.
GetRows Multiple copies of the records from a Recordset object into a two-dimensional array.
GetString The Recordset is returned as a string.
Move In the Recordset object to move the record pointer.
MoveFirst The record pointer to the first record.
MoveLast The record pointer to the last record.
MoveNext The record pointer moves to the next record.
MovePrevious Move the record pointer to the previous record.
NextRecordset Clears the current Recordset object by executing a series of commands and returns the next Recordset.
Open Open a database element, which provides a record of the table, the results of a query or stored Recordset access.
Requery To update the data in a Recordset object by re-executing object-based query.
Resync Refresh the data in the current Recordset from the original database.
Save Recordset object to save the file or Stream object.
Seek Recordset index search to quickly locate the specified value matches the line and makes it the current row.
Supports It returns a Boolean value that define whether a Recordset object supports a specific type of functionality.
Update Save all changes made to a single record in the Recordset object.
UpdateBatch All Recordset changes stored in the database. Use in batch update mode.

event

Note: You can use VBScript or JScript process (only allows Visual Basic, Visual C ++, and Visual J ++ language processing events).

event description
EndOfRecordset When you try to move beyond the end of the Recordset row is triggered.
FetchComplete When the asynchronous operation triggered after all the records are read.
FetchProgress Be triggered periodically during an asynchronous operation, it reports how many records have been read.
FieldChangeComplete Change the value of a Field object is triggered.
MoveComplete Recordset the current position changes after the trigger.
RecordChangeComplete After a recording is triggered change.
RecordsetChangeComplete It is triggered after the Recordset changes.
WillChangeField Be triggered before the value of the object changes Field
WillChangeRecord It is triggered before a record change.
WillChangeRecordset It is triggered before the Recordset changes.
WillMove Recordset is triggered before the current position changes.

set

set description
Fields It indicates the number of this Recordset object Field object.
Properties It contains all Recordset object Property object.

Property Fields collection

Attributes description
Count

Returns the number of fields in the collection of items. Begins at zero.

example:

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

Returns fields in the collection of a specified item.

example:

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

Properties Properties collection

Attributes description
Count

Returns the number of items in a collection of properties. Begins at zero.

example:

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

Returns the properties of a specified item in the collection.

example:

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