Wednesday, August 11, 2010

ASP Cursor


Cursor allows row by row processing of result set. There are four different types of cursors that determine how results of the query are delivered.

Forward Only cursor: 
                              This is the default cursor and provides the fastest performance. Forward only cursor do not support backward scrolling. , allowing only a single pass through the result set.

Static Cursor: 
                   static cursors are similar to forward only cursor however; a static cursor can be used to scroll back and forth through the result set.

Keyset-driven cursor: 
                             A keyset- driven cursor can accurately reflect data that has been updated. How ever it cannot detect whether rows have inserted or deleted by other users. (Deleted rows create holes in the record set). A keyset-driven cursor support scrolling.
Dynamic Cursor: 
                        A dynamic cursor is the richest cursor type. It can detect any changes made to the table by other users while the cursor is open. It also fully supports scrolling. 
To use a richer cursor type an instance of the recordset object needs to be created explicitly and it’s cursor type set before executing the query.



<%              
Set Con = Server.CreateObject(“ADODB.COnnection”)
Con.Open “Filename =”c\datalink.UDL”
Set Rs = Server.CreateObject(“ADODB.Recordset”)
Rs.Cursorlocation = adUseClient
Rs.CursorType = adOpenDynamic”
Rs.Open “SELECT * FROM Auther”, Con
%>
The adovb.inc file was installed on the server when IIS was installed. The file contains list of constants definitions to be used with ado
The following are the list of ADO constants for cursor type.
  • adOpenForwardOnly
  • adOpenStatic
  • adopenKeyset
  • adOpenDynamic
There is one additional option when working with ADO cursors. There is a choice between opening a client side or server side cursor. When the client side cursor is used the cursor is opened and managed on the machine hosting the Active server pages.When the server side cursor is used the cursor is opend and managed on the machine hosting the database.

<!--#Include virtual = “/adovbs.inc” <% 
Set Con = Server.CreateObject(“ADODB.COnnection”) 
Con.Open “Filename =”c\datalink.UDL”
Set Rs = Server.CreateObject(“ADODB.Recordset”)
Rs.Cursorlocation = adUseClient 
Rs.CursorType = adOpenDynamic”
Rs.Open “SELECT * FROM Auther”, Con
%>

5 comments:

  1. what about ref-cursor?

    ReplyDelete
  2. Ref cursor in used in Oracle. It is not a part of ASP cursor type.

    ReplyDelete
  3. pleas need some idea about 'Cursor location'

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. In order to use recordset paging we mostly use cursor location property.The Cursor Location property sets or returns the location of the cursor service. if you need any example on cursor location please let me know.

    ReplyDelete