Pages

Tuesday, November 27, 2012

how to call stored procedure in asp

How to call stored procedure in classic asp --- How to execute store procedure in asp

Simple steps to call stored procedure in ASP

set con = Server.CreateObject("ADODB.Connection")
con.Open strConnect       
Set Comm = Server.CreateObject("ADODB.Command")
comm.ActiveConnection = con
comm.CommandText = "sqlstoredprocedurename"
comm.CommandType = adCmdStoredProc
comm.Parameters.Append comm.CreateParameter("ID" , adVarchar,adParamInput, 50, id)
comm.Parameters.Append comm.CreateParameter("PRODUCT", adVarchar, adParamInput,50, producttype )
comm.Parameters.Append comm.CreateParameter("ACCOUNT", adVarchar, adParamInput,100, "" )
comm.Parameters.Append comm.CreateParameter("O_Errors", adVarchar, adParamOutput,50)  'output parameters
comm.Execute


Monday, September 24, 2012

classic asp session timeout

classic asp session timeout  session object has timeout property


session TimeOut :- Returns the timeout period for a user session. The session timeout period is specified in minutes. if a user does not refresh or request a page within the timeout period the session ends. The default value of the Timeout property in iis  30 mins

syntax for session timeout

<%
session.Timeout = 30
%>

Sunday, September 2, 2012

change session id after login asp

How to change session id after login asp


Risk of not changing session id after login asp 
on accessing the application the users receive a session id which remains constant until the browser instance is used closed. An adversary can hijack session and gain unauthorized access to sensitive information

Step to change session id after login in asp

<% dim ckie1,ckie2,findcolonpos,finalckie
   ckie = Request.ServerVariables("HTTP_COOKIE")
     findcolonpos=InStr(1,ckie,";")
   if findcolonpos>0 then
                ckie1=split(ckie,";")
                ckie2=split(ckie1(1),"=")
        finalckie=ckie2(0)
        else
                ckiename = Mid(ckie,1,(Instr(ckie,"=")-1))
                finalckie=ckiename
        end if

%>
<META HTTP-EQUIV="Set-Cookie" Content="<%=finalckie%>=NULL; path=/">


just put the above code  on top of page after the user gets login to application (eg :- Welcome page)



Monday, July 23, 2012

Server object in Asp

The Asp Server Object can store user defined variables . The variables stored in the Server object are common to all the web pages on the web server. This enables the value to be the same for all the users on all the pages. The Server object contains only one property, ScriptTimeOut. You can use the property  to set the time for which a script is allowed to execute by a server , before it is stopped. For Example, you can specify :-
<% Server.ScriptTimeout  = 50   % >
The previous statement indicates it will allow scripts to run for 50 seconds. The Server will Terminate scripts after 50 seconds  and display an error message This property is useful when a Script is executing a loop with  very high values or waiting for resource to be free. By default the for Scripttimeout property is set to 90 seconds.

ASP SERVER OBJECT METHODS
Method Description
CreateObject Creates an instance of an object
Execute Executes an .asp files
URLEncode Converts a string into the proper format for HTTP paramater passing with escape characters
HTMLEncode Convers HTML string characters to be displayed on a browser instead of being interpreted
MapPath convert a virtual path to phyiscal path
Transfer Transfer control to another ASP page. It does not create a new object context
GetLastError Returns an instance of the ASPError object


Thursday, July 5, 2012

Err Objects Asp (Vbscript)

Error objects 
There are 2 error objects that you can use to handle the errors that occur while creating and executing ASP Code.
  • Err Object
  • ASPError Object 
The err object contains information about runtime errors. It is built in object provided with ASP 2.0 and works with ASP 3.0  You can use the properties of the Err object ot check for errors. For example to raise an error, you need to use the Err.Raise method with appropriate paramaters.

Wednesday, July 4, 2012

On Error Resume Next Asp Vbscript

On Error Resume next Asp

Error Handling using the on error resume next statement asp

The on Error resume next statement in code tells ASP to skip the error and execute the next line of code, instead of stopping the execution of the script. There, a script is completely executed even if there is errors.

Tuesday, July 3, 2012

Types of Error Asp

Identifying the types of Errors in asp

Types of Errors in Asp
  1. Compilation error in asp
  2. Run time error in asp
  3. Logical error in asp
Suppose a visitor to a web page sees the following error message:-
"Microsoft OLE DB Provider for ODBC Drivers error "80004005" [Microsoft][ODBC MICROSOFT ACCESS 97 Driver] The Microsoft jet database engine cannot open the file '(unknown)'. It is already opened opened exclusively by another user, or you need permission to view its data."
Such error prevent visitors from viewing Web pages properly and annoy them. Errors can spoil a well written code in asp. There fore  error handling in asp is extremely important point