The Status.asp module displays the status of a customer's order by using two connections simultaneously. The main steps are:
This application uses the following steps to define the first connection to a database by setting up a Connection object to reference the data source:
The corresponding code follows:
Set connOrder = Server.CreateObject("ADODB.Connection")connOrder.ConnectionTimeout = Session("accts_ConnectionTimeout")connOrder.CommandTimeout = Session("accts_CommandTimeout")
connOrder.ConnectionString = "DSN=Sample;UID=sa;"
connOrder.open
After creating and opening a connection, the application sets up a Command object by using the following steps:
The corresponding code follows:
Set cmdOrder = Server.CreateObject("ADODB.Command")cmdOrder.CommandText = sqlTextcmdOrder.CommandType = adCmdText
After creating a Command object, the application sets up a Parameter object using the following steps:
@piiCustomerID of type Integer with a size of 4
The corresponding code follows:
set p = cmdOrder.Parametersp.Append cmdOrder.CreateParameter("@piiCustomerID", adInteger,
adParamInput, 4)cmdOrder("@piiCustomerID") = Session("CustomerID")
The following code specifies the connection to use:
Set cmdOrder.ActiveConnection = connOrder
This application then uses the following steps to define the second connection to the database by setting up a Connection object to reference the data source:
The corresponding code follows:
Set connLineItems = Server.CreateObject("ADODB.Connection")connLineItems.ConnectionTimeout = Session("accts_ConnectionTimeout")
connLineItems.CommandTimeout = Session("accts_CommandTimeout")
connLineItems.ConnectionString = "DSN=Sample;UID=sa;"
connLineItems.open
After creating and opening the second connection, the application sets up a second Command object by using the following steps:
The corresponding code follows:
set cmdLineItems = Server.CreateObject("ADODB.Command")cmdLineItems.CommandText = "sp_get_line_item_info"cmdLineItems.CommandType = adCmdStoredProc
After creating the second Command object, the application sets up a Parameter object by using the following steps:
@piiOrderNumber of type Integer with a size of 4
The corresponding code follows:
set pp = cmdLineItems.Parameterspp.Append cmdLineItems.CreateParameter("@piiOrderNumber", adInteger,
adParamInput, 4)
The following code executes the first query which returns the first Recordset object:
set rsOrder = cmdOrder.Execute
The following code extracts the values of the Field objects of the first Recordset, and then stores the values in variables:
Do until rsOrder.EOF htmlOrderNumber = rsOrder("OrderNumber") htmlShippingHandlingCharges = rsOrder("ShippingHandlingCharges") htmlTotalOrderPrice = rsOrder("TotalOrderPrice")
htmlSalesTax = rsOrder("SalesTax")
rsOrder.MoveNext
%>
The following code specifies the value to assign to the input parameters of the second command:
cmdLineItems("@piiOrderNumber") = htmlOrderNumber
The following code executes the second query and returns the second Recordset object:
set rs = cmdLineItems.Execute
The following code extracts the values of the Field objects of the second Recordset, stores the values in variables, and then displays them:
Do until rs.EOF htmlLineNumber = rs("LineNumber") htmlProductName = rs("ProductName") htmlItemStatusDescription = rs("ItemStatusDescription") htmlQuantity = rs("Quantity") htmlLineItemPrice = rs("LineItemPrice") rs.MoveNext %> <TR>
<TD WIDTH=50>
<TD WIDTH=75 ALIGN="right"><% = htmlLineNumber %>
<TD WIDTH=240><% = htmlProductName %>
<TD WIDTH=100><% = htmlItemStatusDescription %>
<TD WIDTH=80 ALIGN="right"><% = htmlQuantity %>
<TD WIDTH=80 ALIGN="right"><% = htmlLineItemPrice %>
Sets customizable properties in the Parent Categories Stack. Uses the SHAPE Provider to get a hierarchical recordset.
This application first defines a connection to a database by setting up a Connection object to reference the data source. The steps taken are:
The corresponding code follows:
Set connCategories = Server.CreateObject("ADODB.Connection")
connCategories.ConnectionTimeout=Session("accts_ConnectionTimeout")
connCategories.CommandTimeout = Session("accts_CommandTimeout")
connCategories.ConnectionString="Data Provider=MSDASQL;DSN=Sample;
UID=sa; pwd=;"
connCategories.open
After creating and opening a connection, the application sets up a Command object by using the following steps:
The corresponding code follows:
Set cmdCategories = Server.CreateObject("ADODB.Command")
cmdCategories.CommandText = "sp_get_category_stack"
cmdCategories.CommandType = adCmdStoredProc
After creating a Command object, the application sets up an input Parameter object using the following steps:
@pi_ProductID
of type Integer with a size of 4
The corresponding code follows:
set p = cmdCategories.Parameters
p.Append cmdCategories.CreateParameter("@pii_ProductID", adInteger,
adParamInput, 4)
The following code assigns a value to the input parameter from a session variable:
cmdCategories("@pii_ProductID") = session("ProductID")
The following code specifies the connection to use and then executes the query that returns the Recordset object:
Set cmdCategories.ActiveConnection = connCategories
set rsCategories = cmdCategories.Execute
The following code extracts the value of the Field object from the Recordset, and stores the value in a variable.
iCategoryID = rsCategories("wk_category")
This application now defines a second connection to a database by setting up a Connection object to reference the data source. The steps taken are:
The corresponding code follows:
Set connProperties = Server.CreateObject("ADODB.Connection")
connProperties.ConnectionTimeout=Session("accts_ConnectionTimeout")
connProperties.CommandTimeout = Session("accts_CommandTimeout")
connProperties.ConnectionString="Data Provider=MSDASQL; DSN=Sample;
UID=sa;pwd=;"
connProperties.Provider = "MSDataShape"
connProperties.open
The following code creates a Recordset object:
Set rsProperties = Server.CreateObject("ADODB.Recordset")
The following code uses the Shape provider to define a child Recordset object as the as the value of a Field object in a parent Recordset. It relates the Recordset objects from CategoryProperty and PropertyValue by PropertyID. It creates and appends a new column (chValues) to CategoryProperty. The steps taken are:
The corresponding code follows:
strSQL = "SHAPE {select * from CategoryProperty where CategoryID ="
strSQL = strSQL & iCategoryID
strSQL = strSQL & " }"
strSQL = strSQL & " APPEND ({select * from PropertyValue}"
strSQL = strSQL & " AS chValues RELATE PropertyID to PropertyID)"
The following code specifies the connection to open, query string to use, and assigns the retrieved data to the Recordset object,rsProperties:
rsProperties.Open strSQL, connProperties
The following code first loops through the Parent Recordset, retrieves the appended Recordset and assigns it to rsValues, then displays three fields (PropertyID, PropertyValue, and PropertyDescription) from each row in the appended recordset.
The corresponding code follows:
do until rsProperties.EOF
iPropertyCount = iPropertyCount + 1
htmlPropertyName = rsProperties("PropertyName")
%>
<TD><PRE> </PRE>
<TD><H5><% = htmlPropertyName %></H5>
<TD VALIGN="top">
<%
%>
<SELECT NAME="cboPropertyString<% = iPropertyCount %>">
<%
rsValues = rsProperties("chValues")
while not rsValues.EOF
%>
<OPTION VALUE="<%=(rsValues("PropertyID") & "	" &
htmlPropertyName & "	" & rsValues("PropertyValue")) %>">
<% = rsValues("PropertyDescription") %>
<BR>
<%
rsValues.MoveNext
wend
%>
</SELECT>
<INPUT TYPE="hidden" NAME=iPropertyID<% = iPropertyCount %> VALUE="">
<INPUT TYPE="hidden" NAME=iPropertyName<% = iPropertyCount %> VALUE="">
<INPUT TYPE="hidden" NAME=iPropertyValue<% = iPropertyCount %> VALUE="">
<%
rsProperties.MoveNext
Loop
rsProperties.close
rsCategories.MoveNext
Loop
rsCategories.close