The validatePassword.asp module retrieves and displays the information of one product. The main steps are:
This application first uses the following steps to define a connection to a database by setting up a Connection object to reference the data source:
The corresponding code follows:
Set connPubs = Server.CreateObject("ADODB.Connection")
connPubs.ConnectionTimeout = Session("accts_ConnectionTimeout")
connPubs.CommandTimeout = Session("accts_CommandTimeout")
connPubs.ConnectionString = "DSN=Sample;UID=sa;"
connPubs.open
After creating and opening a connection, the application sets up a Command object by using the following steps:
The corresponding code follows:
Set cmdPubs = Server.CreateObject("ADODB.Command")cmdPubs.CommandText = "sp_validate_password"
cmdPubs.CommandType = adCmdStoredProc
After creating a Command object, the application sets up a Parameter object by using the following steps:
@pivcEmailAddress of type Character with a size of 64
@pivcPassword of type Character with a size of 32
@poiCustomerId of type Integer with a size of 4
@poiReturnCode of type Integer with a size of 4
The corresponding code follows:
set p = cmdPubs.Parameters
p.Append cmdPubs.CreateParameter("@pivcEmailAddress", adVarChar, adParamInput, 64)
p.Append cmdPubs.CreateParameter("@pivcPassword", adVarChar, adParamInput, 32)
p.Append cmdPubs.CreateParameter("@poiCustomerID", adInteger, adParamOutput, 4)
p.Append cmdPubs.CreateParameter("@poiReturnCode", adInteger, adParamOutput, 4)
The following code specifies the values to assign to the input parameters:
cmdPubs("@pivcEmailAddress") = Session("cEmailAddress")
cmdPubs("@pivcPassword") = Session("cPassword")
The following code specifies the connection to use and then executes a command:
Set cmdPubs.ActiveConnection = connPubs
cmdPubs.Execute
The following code assigns the values of the output parameters to session variables:
Session("CustomerID") = cmdPubs("@poiCustomerID")Session("rcPassword") = cmdPubs("@poiReturnCode")