The getAddress.asp module gets the customer's profile, then places output from one row of a resultset into session variables. 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 by object using the following steps:
The corresponding code follows:
Set cmdPubs = Server.CreateObject("ADODB.Command")cmdPubs.CommandText = "sp_get_customer_profile"
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
The corresponding code follows:
set p = cmdPubs.Parameters
p.Append cmdPubs.CreateParameter("@pivcEmailAddress", adVarChar, adParamInput, 64)
The following code specifies the value to assign to the input parameter:
cmdPubs("@pivcEmailAddress") = Session("cEmailAddress")
The following code specifies the connection to use and then executes the query that returns the Recordset object:
Set cmdPubs.ActiveConnection = connPubs
set rsPubs = cmdPubs.Execute
The following code extracts the values of the Field objects of a Recordset, and then stores the values in the session variables:
if not rsPubs.EOF then Session("CreditCardTypeID") = rsPubs("CreditCardTypeID") Session("CustomerStatus") = rsPubs("CustomerStatus") Session("CustomerID") = rsPubs("CustomerID")
Session("CustomerFirstName") = rsPubs("CustomerFirstName")
Session("CustomerLastName") = rsPubs("CustomerLastName")
Session("eMailAddress") = rsPubs("eMailAddress")
Session("Password") = rsPubs("Password")
Session("CustomerAddress1") = rsPubs("CustomerAddress1")
Session("CustomerAddress2") = rsPubs("CustomerAddress2")
Session("CustomerCity") = rsPubs("CustomerCity")
Session("CustomerState") = rsPubs("CustomerState")
Session("CustomerZip") = rsPubs("CustomerZip")
Session("CustomerPhone") = rsPubs("CustomerPhone")
Session("CustomerFax") = rsPubs("CustomerFax")
Session("CreditCardBankName") = rsPubs("CreditCardBankName")
Session("CreditCardNumber") = rsPubs("CreditCardNumber")
Session("CreditCardName") = rsPubs("CreditCardName")
Session("CreditCardExpirationMonth") =
rsPubs("CreditCardExpirationMonth") Session("CreditCardExpirationYear") =
rsPubs("CreditCardExpirationYear")end if