1 / 9

Chapter 9 Building the Shopping cart

Chapter 9 Building the Shopping cart. Objective Creating Shopping cart using session Variable. Creating a shopping cart using a database table. Use the native methods of the ADO to add, delete & update records in a recordset. Using session Variable to create a Shopping cart.

paul-tyler
Download Presentation

Chapter 9 Building the Shopping cart

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 9Building the Shopping cart • Objective • Creating Shopping cart using session Variable. • Creating a shopping cart using a database table. • Use the native methods of the ADO to add, delete & update records in a recordset.

  2. Using session Variable to create a Shopping cart • Every products selected by the customer is add to a cart called shopping cart. • One way to create shopping cart is by assigning an array to session variable. • New items can be added o a shopping cart or existing items can be removed. • This isn’t the best method of creating shopping cart bcoz the shopping cart relies on session variables & sessions variables are notoriously unreliable.

  3. Contd… • When the visitor first arrives at a Web site that uses Session variables, the Web Server adds a cookie to the visitor’s browser that tracks the visitor as he moves from page to page. • When the session variable is created, this cookie is used to associate the variable with the proper user. • If, for whatever reason, the cookie cannot be created on the user’s browsers, the session variables won’t work

  4. Reasons that prevent cookie from being added to a user’s browser. • Some older browser simply don’t support cookies. • The recent browsers provide an option to accept or refuse cookies. • The user’s cookie file may be corrupted. • They time out after a preset period o time [default 20 min]. • Advantage is you need not force the customer to register or log in before adding items to a shopping cart.

  5. Using Database table to create a shopping cart • First create a table.. • Let us create a table named cart and the following is the schema: • Cart_id • Cart_userid • Cart_productid • Cart_quantity

  6. Contd… • As the user selects the product the registration form /log in form is displayed to accept the user’s details along with credit card details. • Every product selected is added to the table just created. • Shopping cart created here is permanent. • Doesn’t rely on the properties of a user’s browser. • Not a single cookie is used.

  7. Native ADO Methods • This is the second method of using the ADO o work with a database. • Native methods of ADO are used to modify database records instead of using the ADO to pass SQL strings to a database. • There is no need of alternative method but in certain situations it is more convenient. • Multiple records in a database table can be updated easily using native methods of ADO.

  8. Creating Updateable Recordset • To modify the records in the Recordset, you must open the Recordset in such a way that it is updateable. • By default the Recordset is read only. • You can open a modifiable Recordset by changing the Recordset’s LockType property. • Statement to open record set: • RS.LockType=adOpenOptimistic • Results in the least interference with other users and is least likely to cause database deadlock.

  9. LockType Property values • adLockReadOnly • adLockPessimistic • adLockOptimistic • adLockBatchOptimistic

More Related