Saturday, November 24, 2007
Working with Transactions with an SQL Server Database
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 you
how 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.
The code that performs this task fires when the ASP.NET page loads:
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs) Within that procedure you will need a Connection object and a Command object:
Dim DBConn as SQLConnection Dim DBDelete As New SQLCommand
You will also need a Transaction object:
Dim DBTrans As SQLTransaction
You start by connecting to the SQL Server database:
DBConn = New SQLConnection("server=localhost;"
& "Initial Catalog=TT;" _
& "User Id=sa;" _
& "Password=yourpassword;")
and opening that connection:
DBConn.Open()
You then start a transaction by calling the BeginTransaction method of the Connection object. That method returns an open transaction, which is placed into the local Transaction object:
DBTrans = DBConn.BeginTransaction()
The Command object will connect to the database through the Connection object:
DBDelete.Connection = DBConn
It will also use the Transaction object:
DBDelete.Transaction = DBTrans
Next, two records are deleted and executed from the Employees table:
DBDelete.CommandText = "Delete From Employees
& "Where EmpID = 1" DBDelete.ExecuteNonQuery() DBDelete.CommandText = "Delete From Employees
& "Where EmpID = 2"DBDelete.ExecuteNonQuery()
But the records are not actually deleted from the database since the RollBack method of the Transaction object is called:
DBTrans.RollBack()
lblMessage.Text = "No action was taken."
The RollBack method causes the queries that were executed within the Transaction object to be cancelled.
You could instead call the Commit method:
'DBTrans.Commit()
['his method causes the pending execute statements to be executed as a group so that they fail or succeed together.
Tuesday, November 20, 2007
Text, Color Schemes, Images, Copy and Virtual Bundles
Text, Color Schemes, Images, and Copy
If people feel good, they typically purchase more. With the convenience of having multiple stores at a shopper's fingertips, an online store must be inviting and must ensure that the customer feels comfortable to stay and purchase. The web also has the potential of becoming more like catalogs and having a more recreational aspect versus a pure product hunt.
Effective online merchandising considers advertisement and newspaper techniques. They start with the most important attributes and put them in the headlines and sub-headlines. These same techniques must be applied online—with the most important customer benefits up top as the headline.
Some products are complex to describe, such as those with textures and other sensory attributes that would make the sale in retail. A silky, luxurious blouse in rich colors can be described with words and images, but subtle variations in the difference between sueded-silk and satin may not be easily described. Magnifying glass "close up" techniques can give a deeper view. This technique, coupled with appropriate copy writing and other imagery, can enhance product details and simulate the retail environment. For expensive items, such as a large line of name-brand quality clothing, you may consider providing a swatch sample for your shoppers to order prior to purchasing.
Virtual Bundles—E-kits
Special product bundles have been a retail strategy to stimulate sales. Bundles consist of two or more products or a product with a special offer. At retail, physical bundles are created by putting two or more products into the same box or by strapping the products together to form a "hard" bundle. A new SKU number is created and assigned to the new "package" so it can be stocked, inventoried, and merchandised.
Online stores have an advantage over retail because they can create "virtual" bundles. Virtual bundles put the products or special offers together on the product detail page—the online "package." The virtual bundle is also assigned a new SKU number. Fulfillment can be notified to "pick and pack" those items that make up the bundle. Virtual bundles save on production costs and labor, because a physical hard-bundled product is not required. A hard bundle is created virtually through putting the separate items into the same shipping box.
These elkits require special merchandising treatments, however, because they are mot physically bundled items in one package. New photos may be required to show the bundle contents. All product categories are eligible for bundling. Dresses with handbags, crafts with tools, printers with cartridges, and dog food with dog toys are a few combinations. Bundles are limited only by the imagination and distribution capabilities. Bundles provide you a competitive advantage by providing "new" exclusive items for your target customers.