YouTip LogoYouTip

Ado Ref Recordset

## Instance (#) This example demonstrates how to use the GetRows method. * * * ## Recordset Object The ADO Recordset object is used to hold 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 frequently used object for manipulating data in a database. ### ProgID set objRecordset=Server.CreateObject("ADODB.recordset") When you first open a Recordset, the current record pointer will point 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 you call the Update method, all changes are immediately written to the database. Batch update - the provider will cache multiple changes, and then use the UpdateBatch method to transmit these changes to the database. In ADO, 4 different cursor types are defined: * Dynamic Cursor - Allows you to view additions, changes, and deletions made by other users * Keyset Cursor - Similar to a dynamic cursor, except that you cannot view additions made by other users, and it prevents you from accessing records deleted by other users. Data changes made by other users are still visible. * Static Cursor - Provides a static copy of the record set, which 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 cursor type allowed when you open a client-side Recordset object. * Forward-only Cursor - Only allows forward scrolling in the Recordset. 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. * * * ## Properties | Property | Description | | --- | --- | | AbsolutePage | Sets or returns a value that specifies the page number in the Recordset object. | | AbsolutePosition | Sets or returns a value that specifies the ordinal position of the current record in the Recordset object. | | ActiveCommand | Returns the Command object associated with the Recordset object. | | ActiveConnection | If the connection is closed, sets or returns the definition of the connection; if the connection is open, sets or returns the current Connection object. | | BOF | Returns true if the current record position is before the first record, otherwise returns false. | | Bookmark | Sets or returns a bookmark. This bookmark saves the position of the current record. | | CacheSize | Sets or returns the number of records that can be cached. | | CursorLocation | Sets or returns the location of the cursor service. | | CursorType | Sets or returns the cursor type of a Recordset object. | | DataMember | Sets or returns the name of the data member to be retrieved from the object referenced by the DataSource property. | | DataSource | Specifies an object that contains data to be represented as a Recordset object. | | EditMode | Returns the edit state of the current record. | | EOF | Returns true if the current record position is after the last record, otherwise returns false. | | Filter | Returns a filter for the data in the Recordset object. | | Index | Sets or returns the name of the current index of the Recordset object. | | LockType | Sets or returns a value that specifies the type of locking when editing a record in the Recordset. | | MarshalOptions | Sets or returns a value that specifies which records are returned to the server. | | MaxRecords | Sets or returns the maximum number of records to return to a Recordset object from a query. | | PageCount | Returns the number of data pages in a Recordset object. | | PageSize | Sets or returns the maximum number of records allowed on a single page of a Recordset object. | | RecordCount | Returns the number of records in a Recordset object. | | Sort | Sets or returns one or more field names that are the sort criteria for the Recordset. | | Source | Sets a string value, or a Command object reference, or returns a string value that indicates the data source of the Recordset object. | | State | Returns a value that describes whether the Recordset object is open, closed, connecting, executing, or fetching data. | | Status | Returns the status of the current record regarding batch updates or other bulk operations. | | StayInSync | Sets or returns whether the reference to the child records changes when the parent record position changes. | ## Methods | Method | Description | | --- | --- | | AddNew | Creates a new record. | | Cancel | Cancels an execution. | | CancelBatch | Cancels a batch update. | | CancelUpdate | Cancels changes made to a record of the Recordset object. | | Clone | Creates a duplicate of an existing Recordset. | | Close | Closes a Recordset. | | CompareBookmarks | Compares two bookmarks. | | Delete | Deletes a record or a group of records. | | Find | Searches for a record in a Recordset that satisfies a specified criterion. | | GetRows | Copies multiple records from a Recordset object into a two-dimensional array. | | GetString | Returns the Recordset as a string. | | Move | Moves the record pointer in a Recordset object. | | MoveFirst | Moves the record pointer to the first record. | | MoveLast | Moves the record pointer to the last record. | | MoveNext | Moves the record pointer to the next record. | | MovePrevious | Moves 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 | Opens a database element that provides access to records of a table, the results of a query, or a saved Recordset. | | Requery | Updates the data in a Recordset object by re-executing the query on which the object is based. | | Resync | Refreshes the data in the current Recordset from the original database. | | Save | Saves the Recordset object to a file or Stream object. | | Seek | Searches the index of the Recordset to quickly locate the row matching the specified value and make it the current row. | | Supports | Returns a boolean value that defines whether the Recordset object supports a particular type of functionality. | | Update | Saves all changes made to a single record in the Recordset object. | | UpdateBatch | Saves all changes in the Recordset to the database. Use in batch update mode. | ## Events Note: You cannot use VBScript or JScript to handle events (only Visual Basic, Visual Visual C++, and Visual J++ languages can handle events). | Event | Description | | --- | --- | | EndOfRecordset | Triggered when attempting to move to a line beyond the end of the Recordset. | | FetchComplete | Triggered after all records in an asynchronous operation have been read. | | FetchProgress | Triggered periodically during an asynchronous operation to report how many records have been read. | | FieldChangeComplete | Triggered when the value of a Field object changes. | | MoveComplete | Triggered after the current position in the Recordset changes. | | RecordChangeComplete | Triggered after a record changes. | | RecordsetChangeComplete | Triggered after the Recordset changes. | | WillChangeField | Triggered before the value of a Field object changes. | | WillChangeRecord | Triggered before a record changes. | | WillChangeRecordset | Triggered before the Recordset changes. | | WillMove | Triggered before the current position in the Recordset changes. | ## Collections | Collection | Description | | --- | --- | | Fields | Indicates the number of Field objects in this Recordset object. | | Properties | Contains all Property objects in the Recordset object. | ## Properties of the Fields Collection | Property | Description | | --- | --- | | Count | Returns the number of items in the fields collection. Starts at 0. Example: countfields = rs.Fields.Count | | Item(named_item/number) | Returns a specific item in the fields collection. Example: itemfields = rs.Fields.Item(1) or itemfields = rs.Fields.Item("Name") | ## Properties of the Properties Collection | Property | Description | | --- | --- | | Count | Returns the number of items in the properties collection. Starts at 0. Example: countprop = rs.Properties.Count | | Item(named_item/number) | Returns a specific item in the properties collection. Example: itemprop = rs.Properties.Item(1) or itemprop = rs.Properties.Item("Name") |
← Ado Ref StreamAdo Ref Record β†’