Tuesday, March 9, 2010

Classic ASP Basics - 1

global.asa

==========



application events

session events

object declarations

TypeLibrary declarations

#include directive



======================









You could reference the object "MyAd" from any page in the ASP application:



<%=MyAd.GetAdvertisement("/banners/adrot.txt")%>



========================



Calling stored procedure from ADO

=================================



Set cn = Server.CreateObject("ADODB.Connection")

Set cmd = Server.CreateObject("ADODB.Command")

cn.Open "data source name", "userid", "password"

Set cmd.ActiveConnection = cn

cmd.CommandText = "sp_test"

cmd.CommandType = adCmdStoredProc

' Ask the server about the parameters for the stored proc

cmd.Parameters.Refresh

' Assign a value to the 2nd parameter.

' Index of 0 represents first parameter.

cmd.Parameters(1) = 11

cmd.Execute

%>

Calling via method 1


ReturnValue = <% Response.Write cmd.Parameters(0) %>



Cursors types in ADO

====================



1) adOpenDynamic :- Additions, Changes and Deletions by other users will be visible

2) adOpenKeyset :- Only changes will be visible. Additions and Deletions are not visible.

3) adOpenStatic :- Additions, Changes and Deletions by other users are not visible. Used for disconnected recordset model.

4) adOpenForward-only :- Additions, Changes and Deletions by other users are not visible. To only scroll forward only.



Cursor Locations in ADO

=======================



adUseNone

adUseServer

adUseClient (read only)

adUseClientBatch



Cursor Lock types in ADO

=======================



adLockPessimistic - Locks the row once after any edits occur.

adLockOptimistic - Locks the row only when Update is called.

adLockBatchOptimistic - Allows Batch Updates.

adLockReadOnly - Read only. Cannot alter the data.



Disconnected Recordset

=======================



set con= server.createobject("ADODB.Connection")

set rs= server.createobject("ADODB.Recordset")

rs.CursorLocation=adUseClient

con.open sqlcon

rs.open sqlqry, con, adOpenStatic, adLockBatchOptimistic

Set oRS.ActiveConnection = Nothing

Set GetanotherRS = oRS



Clustered and nonclustered indexes

=================================



Clustered indexes contains actual data at leaf nodes

non clustered indexes contains row locators that point to actual data. 249 -> 999





No comments:

Post a Comment