Anatomy of the Online Store

Some of these parts, electronic product catalogs, were related to structure and were developed in a variety of database-driven architectures. The online store that relies solely on a database-driven product database is weak and cannot withstand competition or support customer needs. These early electronic catalogs displayed long lists of products to online customers. They lacked intuitive organization and structure.A strong online store is dependent on having the right elements, which consist of structure, form, and navigation. It is also dependent on having the right product mix, sufficient customer research, intuitive navigation and ease of use, and a good delivery and fulfillment mechanism. Information must be adequate and appropriate. The basic elements of the store €”the web pages €”must fluidly guide the customers to desired destinations. Customer-centered web design reverses the typical development order for websites. The typical method is to take an existing product database and build a user interface on top of it to accommodate the existing category structure. The customer-centered method starts with the user interface and builds the database structures and content to accommodate the page layout and content requirements of the customer and merchant. The user interface requires specific online merchandising techniques to influence effectiveness and design simplicity.

Adding Sub Methods to a Web Service

A Web service is typically made up of many different methods. These methods can be either Subs or Functions. Functions return a value and Subs do not. This tip shows you how to define Subs in an ASP.NET Web service.USE 1T The methods created for this Web service add to the functionality of the Tips Web service. The Web service contains two Subs.The first Sub provides the method for adding a tip to the Access database. That method has this definition:

You start with the WebMethod tag, which indicates that the method is exposed through your Web service:

Also on that line, you indicate that the method is a Sub and its name is AddTip. The method has two parameters that need to be passed into it. The first is the title of the tip and the second is the text of the tip. Both must be passed in as strings.Since you need to add data to the database, you need these data objects:

and indicate that the Command object will connect to the database through the Connection object:

Next, you add a record to the database based on the title and text passed into this method:

The other Sub defined in this Web service allows for the deletion of a tip from the Access database:

This method needs to have a number passed into it, which is the ID of the tip that is to be deleted:

For this method, you will need data objects:

You start by connecting to the Access database:

You then delete the record that has an ID that matches the ID that was passed into this Sub:

Working with Transactions with an SQL Server Database

Transactions provide a way for you to group together database executions as a group so that they succeed or fail together. For example, if you had an e-commerce site you may have code that allows visitors to add a quantity of an item to their shopping cart. When you do that you also want to remove the number of items ordered from your inventory.Therefore, you have two actions that you need to execute. You want to add items to a shopping cart and you want to remove items from inventory.These executions need to happen as a group. You don’t want to add items to the shopping cart if something goes wrong with removing them from inventory. And the opposite is also true.Therefore, the database executions need to be grouped in a Transaction. This technique shows youhow to use a Transaction object with an SQL Server database.This ASP.NET page contains SQL Delete statements that delete records from the Employees table. But the records are not deleted because they are in a transaction and the transaction is not committed to the database.

Retrieving Data from a Stored Procedure

Stored procedures frequently return data from a database. They can return single values, tables joined together, or all the records from a single value, and much more. You can call stored procedures that return data from your ASP.NET pages. This technique shows you how to do that..The stored procedure defined in the SQL Server database has this definition:CREATE PROCEDURE CurrentMonthBirthDays AS Select * from Employees Where Month(BirthDate) = Month(GetDate())Notice that the GetDate function, which returns the current system date, is used to see if the month of that date matches the month of the birth date.

Updating SQL Server Data by ASP.Net

Another type of query that you will often need to run on your ASP.NET pages that include database connectivity are Update queries. Update queries allow you to modify existing records in an SQL Server database table. This technique shows you how to run an Update query from your ASP.NET code.The page presented with this technique allows the visitor to give all the employees in the Employees table a raise. The visitor enters the factor for the raise and every employee has their salary increased by that factor.Defined on the ASP.NET page is this TextBox control for entering the raise amount.