The recordset object has several properties, methods, and events that are exposed to scripting. The following tables provide a brief description of each.
Property | Purpose | Syntax |
absolutePosition | specifies the absolute position of the current record | recordset.absolutePosition[=index] |
BOF | indicates whether the cursor is positioned before the first record | recordset.BOF |
EOF | indicates whether the cursor is at the end of the recordset | recordset.EOF |
fields | specifies an instance of the Fields object | recordset.fields |
id | returns a unique identifier for the object | recordset.id |
maintainState | specifies whether object state is maintained during server processing | recordset.maintainState[=boolean] |
name | returns the name of the object | recordset.name |
Method | Purpose | Syntax |
addRecord | creates a new record in the recordset | recordset.addRecord() |
advise | registers an object to be notified when a specified event occurs and to call a particular function | recordset.advise(event, function) |
cancelUpdate | cancels any changes being made to the current record | recordset.cancelUpdate() |
close | closes the recordset object | recordset.close() |
deleteRecord | deletes the current record | recordset.delete() |
getBookmark | returns a bookmark for the current record | recordset.getBookmark() |
getConnectString | returns a string or object that specifies the data connection | recordset.getConnectString() |
getCount | returns the number of records in the recordset | recordset.getCount() |
getDHTMLDataSourceID | returns a string from the DHTML data source's ID | recordset.getDHTMLDataSourceID() |
getParameter | returns a parameter from a stored procedure or parameterized query | recordset.getParameter(index) |
getRecordSource | returns the ADO recordset object | recordset.getRecordSource() |
getSQLText | returns the SQL statement that queries the database | recordset.getSQLTextg() |
isOpen | returns whether the recordset object is open | recordset.isOpen() |
move | moves the cursor the specified number of positions | recordset.move(records) |
moveAbsolute | moves the cursor to the specified record | recordset.move(index) |
moveFirst | moves to the first record in the recordset | recordset.moveFirst() |
moveLast | moves to the last record in the recordset | recordset.moveLast() |
moveNext | moves to the next record in the recordset | recordset.moveNext() |
open | opens a recordset object | recordset.Open() |
requery | requerys the database | recordset.requery() |
setBookmark | sets a bookmark to a particular record | recordset.Bookmark(bookmark) |
setParameter | sets a parameter for a parameterized query or stored procedure | recordset.setParameter.(index, parameter) |
setRecordSource | sets connection properties for opening a recordset object | recordset.setRecordSource(ADO|conn,SQL) |
setSQLText | sets the SQL statement to query the database | recordset.setSQLText(sql) |
unadvise | cancels the registration of an object | recordset.unadvise(event, id) |
updateRecord | updates the current record | recordset.updateRecord() |
Event | Occurs | Syntax |
onafterupdate | after a record is updated | recordset_onafterupdate |
onbeforeopen | just before a recordset object is opened | recordset_onbeforeupdate |
onbeforeupdate | just before a record is updated | recordset_onbeforeupdate |
ondatasetchanged | when a change is made to the recordset object | recordset_ondatasetchanged |
ondatasetcomplete | when the server finishes downloading the recordset | recordset_ondatasetsomplete |
onrowenter | when the cursor moves to another record | recordset_onrowenter |
onrowexit | when the cursor moves to another record | recordset.onrowexit |
You have already used recordset objects in some of the exercises. When a Recordset Design-Time control is inserted into a page, it creates a recordset object and some
to set up some of the object's properties. You can see the script by right-clicking the control and selecting Show Runtime Text. In this lesson you will learn to use the recordset object via script.
The following image and MouseOver shows script from within the source editor of the file Specials. The Textbox DTCs have been replaced with server-side script, and the script is bound to the Recordset DTC to display the data. The purpose of Specials.asp is to display only books that are on special. To do this, we will use script to change the recordset object's default behavior from retrieving all records to retrieving only records who's Status field equals 'S.' In this example, the
event is used to change the default query before the recordset object is opened.