Welcome to
Beginning ASP.NET 2.0 E-Commerce in C# 2005!

- code download notes and errata -

(version 0.8, April 07, 2006)
 

Dear Reader,

Thank you for buying Beginning ASP.NET 2.0 E-Commerce in C# 2005! We really hope you'll enjoy reading this book, and that it will effectively help you build your own websites with ASP.NET 2.0, C# 2005, and SQL Server!

Please read the remainder of this document carefully because it contains updated information, including errata. If you have any questions or suggestions, don't hesitate to contact Cristian Darie through his personal website at http://www.cristiandarie.ro (expect to receive a reply in maximum 15 days).

Also, please don't hesitate to post an Amazon review if you happen to like the book, or if you have any suggestions that might help other potential readers decide if the book would be useful for them. Be honest and let the world know what you think.

Thank you!

Cristian Darie and Karli Watson

 

Code Download Release Notes

The code in this book has been tested with the final versions of Visual Studio 2005 Professional Edition, Visual Web Developer 2005 Express Edition, and SQL Server 2005.

The code does not work with Visual Studio 2003, and there's no easy way to port it to ASP.NET 1.1. If you need to use ASP.NET 1.1, then you might want to check Beginning ASP.NET 1.1 E-Commerce. If you need to use SQL Server 2000 (or MSDE) instead of SQL Server 2005, you can do with a few changes to the SQL code.

[update] One detail that changed since we wrote the book is about SQL Server 2005 Express Manager. This utility allowed you to connect to, and execute SQL scripts in a SQL Server 2005 instance. In the meantime that utility has been replaced by SQL Server Management Studio Express. Find a link to the download page at http://lab.msdn.microsoft.com/express/sql/. After installing the product, you can find it under Start | Programs | Microsoft SQL Server 2005 | SQL Server Management Studio Express.

This document will be updated in response to your feedback. I will send announcements about these kinds of updates (a few announcements every year) through my newsletter. Subscribe by sending a blank email to cristiandarienews-subscribe@yahoogroups.com, or simply click here.

 

Using the Code Download

This archive contains all the code presented in the book. However, if you can afford the time, try to write the code yourself, following the exercises from the book. The only bit of this archive which can't be found in the book are the image folders.

This archive contains three main folders:

ImageFolders
This folder contains the Images and ProductImages folders which you'll need for BalloonShop (the sample e-commerce site you're building in this book).

Code
Here you'll find the code for the BalloonShop project. For the first 11 chapters, the complete code is included. For chapters 12-16, because the code is advanced and generally needs customization, we thought it would be more useful to include only the bits specific to those chapters. So if you'll want to go through the book as quickly as possible, you'll need to start with the code from chapter 11, and the dig your way to the end of the book.

Database
This folder contains the database creation scripts for the tables, stored procedures, and functions. You can find the SQL scripts grouped by chapter, in files named chapter02.sql, chapter03.sql, and so on. You can also find the complete script for chapters 02 through 11 in a file named complete_script_chapters_02-11.sql (note that this script assumes the BalloonShop database doesn't exist, so it creates it).

You can also find a subfolder called INSERTs, which contains the PopulateDepartment.sql, PopulateCategory.sql, PopulateProduct.sql and PopulateProductCategory.sql files that insert the sample data to the tables. You'll want to use these files if you decide to create your data structures manually and not use the chapterXX.sql files, which contain the INSERT statements as well. When using the Populate scripts, your data tables must be newly created (or recently TRUNCATEd), because the new autogenerated IDs must start with 1 (otherwise the associations between the table records won't work).

 

Errata

The errata list will be constantly updated in response to your feedback. Many thanks to Racanti Stefano, Stephen Gilkes, Benjamin R. Adamski and Mark Miccio for providing essential technical feedback and errata reports, helping many other book readers (and me!) with their effort.

Page 38, exercise step 1
You are instructed to copy the
ImageFolders\Images folder from the code download to your project's folder. It should be more clearly specified that you need to copy just the Images folder, and not place it inside an ImageFolders folder as it is in the code download.

Page 42, the "Create New SQL Server Database" link is grayed out in Database Explorer
Many readers have reported this problem. I didn't find out the exact circumstances, but I can tell two workarounds:
1) Instead of "Create New SQL Server Database", choose "Add Connection". After filling connection details, write "BalloonShop" for the database name. After clicking OK, a confirmation box will show up saying "The database BalloonShop does not exist. Would you like to create it?". Choose Yes.
2) The alternative would be to use the SQL Server Management Studio Express utility instead.

Page 77
In the paragraph following the second code snippet,
SqlCommand should read SqlConnection, OracleCommand should read OracleConnection, and DbCommand should read DbConnection.

Page 81, paragraph 1
The
System.Web.Mail namespace mentioned has been replaced in .NET 2.0 with System.Net.Mail.

Page 82/83, exercise steps 4&6
The file you create at step 4 should be called
BalloonShopConfiguration.cs instead of ApplicationConfiguration.cs. The class name mentioned at step 6 should be BalloonShopConfiguration instead of ApplicationConfiguration.

Page 85
In the
SendMail method there is a portion of commented code that shows how to deal with SMTP servers that require authentication. In case that doesn't work, set SMTP authentication with this line of code instead:

mailClient.Credentials = new System.Net.NetworkCredential(SmtpHostUserName, SmtpHostPassword);

Page 86, line 3
BalloonShopConfiguration.SiteName will be defined at page 137. Until then, you'll need to hard-code the name of your site:
      string subject = "BalloonShop Error Report";

Page 101-102
The mentioned error doesn't show up until chapter 4, when the
DepartmentID query string parameter will be read and used.

Page 118
The description of figures 4-10 and 4-11 should be "Creating the
ProductCategory table" instead of "Creating the Product table".

Page 120, exercise step 12
"the same way you did in steps 11 and 12" should refer to steps 10 and 11 instead.

Page 142
"Add the
ProductDetails struct at the beginning of Catalog.cs" should read "Add the ProductDetails struct at the beginning of CatalogAccess.cs".

Page 147
"you are redirected to
Catalog.aspx (which at this moment doesn't exist)". This is inaccurate because the Catalog.aspx page was created at page 97, exercise step 12.

Page 158
Step 5 of the exercise instructs you to change the
RepeatDirection property to Horizontal. Yet, neither the code snippet at step 6, nor the code download, contains that property.

Page 339
The shopping cart price and subtotal don't display using the currency format even if steps 9 and 10 are followed correctly. To fix the problem you need to set the
HtmlEncode property of the Price and Subtotal bound fields to false. The problem is explained here: http://weblogs.asp.net/rajbk/archive/2005/10/31/429090.aspx.

Page 346
The
DeleteProduct stored procedure shouldn't receive a CategoryID parameter. The correct code for altering the procedure is:

ALTER PROCEDURE DeleteProduct
(@ProductID INT)
AS
DELETE FROM ShoppingCart WHERE ProductID=@ProductID
DELETE FROM ProductCategory WHERE ProductID=@ProductID
DELETE FROM Product where ProductID=@ProductID

Page 382
In certain circumstances, you may end up having orders in the database that contain no products. When trying to view these orders from the administration page, you'd get an error because the total amount value returned from the database is
NULL, and cannot be converted successfully to decimal by the C# code. To have your solution bulletproof, you need to use the ISNULL function in OrderGetInfo, so that the stored procedure would return 0 instead of NULL for orders with no products (this technique is used in the ShoppingCartGetTotalAmount at page 320). Use ALTER instead of CREATE if you already have the stored procedure in your database:

CREATE PROCEDURE OrderGetInfo
(@OrderID INT)
AS
SELECT OrderID,
(SELECT ISNULL(SUM(Subtotal), 0) FROM OrderDetail WHERE OrderID = @OrderID)
...