Updating the Shopping Basket
Introduction. Now
we need to develop an ASP that will be used for updating the items in a shopping basket. The file will be called
UpdateBasket.asp.
This will be presented after discussing
stored procedures.
We will need two stored procedures to update the shopping basket. Both of them have already been developed, sp_RetrieveBasketItem and sp_UpdateBasketItemsQuantity. The following table displays the name of the stored procedures and the ASP file in which it is called. |
Stored Procedure | ASP Container |
sp_RetrieveBasketItem sp_UpdateBasketItemsQuantity |
UpdateBasket.asp |
The Basket.asp.
Since we have already created the stored procedures required for this
ASP, one of the advantages of using stored procedures, we can readily
make use of them. The following UpdateBasket.asp
will
|
<%@ Language=VBScript %> <% ' **************************************************** ' UpdateBasket.asp - This page will read in new quantity for ' items in the basket and set them appropriately. ' **************************************************** ' Create an ADO database connection set dbBasketItem = server.createobject("adodb.connection") ' Create a record set set rsBasketItem = server.CreateObject("adodb.recordset") ' Open the connection using our SQL Server DSN-less connection string dbBasketItem.ConnectionString="Driver={SQL Server}; Server=cisdev.quinnipiac.edu;" & _ "Database=WildWillies;UID=cis; PWD=csatqu" dbBasketItem.Open ' Retrieve the basket items sql = "execute sp_RetrieveBasketItem " & session("idBasket") ' Execute the SQL statement set rsBasketItem = dbBasketItem.Execute(sql) ' Create an ADO database connection set dbUpdateItem = server.createobject("adodb.connection") ' Create a record set set rsUpdateItem = server.CreateObject("adodb.recordset") ' Open the connection using our SQL Server DSN-less connection string dbUpdateItem.ConnectionString="Driver={SQL Server}; Server=cisdev.quinnipiac.edu;" & _ "Database=WildWillies;UID=cis; PWD=csatqu" dbUpdateItem.Open ' Loop through the basket items do until rsBasketItem.EOF
loop |
Notice that this ASP is essentially purely a processing
script. There isn't any HTML associated with the display.
After the results are developed, the Basket.asp is called to display
them.
You should also notice that this ASP page updates only the order quantities. It could also be worthwhile to enhance this feature to allow modification of other things in the order. |