This document describes the various aspects of ASP develoment. Active Service Pages (ASP) is a Microsoft Technology used for server side computation for web based systems. It gets executed on a Internet Information Server (IIS).
1.1 Standard Variables
Some standard variables are available globally in a ASP environment.
These variables are:
Request object is available in the ASP environment. It contains all the form values which gets posted to the web server. The values from the Request object can be obtained by two ways. If the form actions is Post, then the values should be returned using the Form() method.
And for Get action, QuseryString() method should be used.
If we are not sure whether to retrieve from Form or QueryString, just get it from the Request object
Response object sends the reponse back to the client. Some of the operations of Response object are
Response.Write "An Error has occurred: " & Err.Description
The End operation on the Response object will make the server to display whatever on the Response object on the page. The redirect method will take the user to the redirected page.
Session object is a place holder object in the web server. It can be used to retain values between user requests.
‘to get the value
Set value = Session("key")
‘to set value
set Session("key") = value
Server is the object which performs operation on the host machine. New objects can be created using the creatObject method
set rs = server.CreateObject ("ADODB.Recordset")
2 VB Script
VB Script can be used for serve side scripting on ASP pages. The VB script are marked with <% %> and <%= %>. The tag with the = places the value on the page. The followi9ng sections describe the various functions available
2.1 String Operations
gets the portion of the string from left side
This will get 7 characters from left side
gets the portion of the string from right side
This will get 7 characters from Right side
is used to grab characters from the middle of a string
Mid(str1, 20, 7)
This will get 7 characters from the 20th position
This method searches for a string in another string and returns the beginning position of the found string
arrowPos = InStr(20, str1, ">")
This will search for “>” in String str1 starting from position 20
This method will split the string into a series of substrings based on a delimiter
namevalues = Split(str1, ",")
This will split the string str1 with delimiter as comma and returns an array of substrings
& will append two strings
str3 = str1 & “ “ & str2
This will append str1 and str2 with a space in between
ADO is ActiveX Data Objects which are used for accessing databases like MS Access DB, SQL Server, Excel Spread sheet etc. ADO comes with the following classes
Connection object is used to connect to a data source, remote or local
conn = server.CreateObject("ADODB.Connection")
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\example.mdb"
This is the result object, returned after a query is executed
Set rs = server.CreateObject ("ADODB.Recordset")
rs.Open(SQLString, conn, 0, 1)
While Not rs.EOF
Value1 = rs("key1")
The example above creates a resultset object and opens it for a sql query SQL String by using a connection object conn. Then it loops through the recordset and retrieves values out of it.