Recordset In ASP

Tips >> ASP

 



This article describes how to use the PageSize, PageCount, and Absolute Page properties of an ADO recordset and what cursor types must be used to get Recordset Paging to work. Every once in a while you may be comming across the task of displaying a large number of records in ASP pages. The good example is displaying the results of a search. Most of the time you do not know the number of records that you have to display in advance. In addition to this, as the usage of the application growth the size of the database will grow accordingly. That leaves you as well as anyone with the similar application requirements no other choice, but to develop some kind of algorithm to display records in the smaller portion of pages.The ADO Recordset object is used to hold a set of records from a database table. A Recordset object consist of records and columns (fields).

In ADO, this object is the most important and the one used most often to manipulate data from a database.

Everyone is familiar with the way search results are displayed by Internet search engines. You get the first page of results that are limited to some number of records and some nearest links to go to the first, previous, next or the last page. Some sites give you the ability to go directly to specific page number, some use a mixture of both.

The second page of the article should be capable of following the following rule :-

  • Receive the Keyword that user have entered.
  • Search the database for records containing Keyword.
  • Display a page of resulting records.
  • Provide user with some navigation links to display more pages of results if needed.

Recordset objects can support Two Types of Updating :-

  • Immediate updating :- All changes are written immediately to the database once you call the Update method.

  • Batch updating :-The provider will cache multiple changes and then send them to the database with the UpdateBatch method.

In ADO there are Four Different Cursor types defined :-

  • Dynamic cursor :- Allows you to see additions, changes, and deletions by other users.
  • Keyset cursor :- Like a dynamic cursor, except that you cannot see additions by other users, and it prevents access to records that other users have deleted. Data changes by other users will still be visible.
  • Static cursor :- Provides a static copy of a recordset for you to use to find data or generate reports. Additions, changes, or deletions by other users will not be visible. This is the only type of cursor allowed when you open a client-side Recordset object.
  • Forward-only cursor :- Allows you to only scroll forward through the Recordset. Additions, changes, or deletions by other users will not be visible.

 

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

The Methods of the Recordset are as follows :-

Method Description
AddNew Creates a new record.
Cancel Cancels an execution.
CancelBatch Cancels a batch update.
CancelUpdate Cancels changes made to a record of a 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 criteria.
GetRows Copies multiple records from a Recordset object into a two-dimensional array.
GetString Returns a 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 and returns the next Recordset object by looping through a series of commands
Open Opens a database element that gives you access to records in a table, the results of a query, or to a saved Recordset
Requery Updates the data in a Recordset by re-executing the query that made the original Recordset
Resync Refreshes the data in the current Recordset from the original database
Save Saves a Recordset object to a file or a Stream object
Seek Searches the index of a Recordset to find a record that matches the specified values
Supports Returns a boolean value that defines
whether or not a Recordset object supports a specific type of functionality
Update Saves all changes made to a single record in a Recordset object
UpdateBatch Saves all changes in a Recordset to the database. Used when working in batch update mode


 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

+91-9967648641

+91-9967648641