This project is read-only.


11/05/2008 21:36:06

This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005.
The Storefront sample for the Adventure Works Cycles sample database in SQL Server demonstrates how to build a simple Internet retail application by using SQL Server, ADO.NET, and ASP.NET. This document describes how to install the SQL Server version of the sample application.
This sample works with the AdventureWorks sample database, which is included with SQL Server. Updates for both the database and this sample are available to download at the CodePlex Web site.
Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications and assemblies should not be connected to or used with your production SQL Server database or your report server without the permission of the system administrator.
The default installation directory is C:\Program Files\Microsoft SQL Server\100\Samples\Integrated Samples\Storefront\.


A developer wants to implement an e-commerce Web site. The Web site should offer additional product recommendations based on the contents of the shopping cart (product up sell).


Transact-SQL, XML, XSD, Visual C#, and Visual Basic.


The Storefront sample uses the following features of SQL Server:

Application Area Features
Demographics XML, XSD
Globalization Common language runtime user-defined function, common language runtime user-defined type
Overall ADO.NET, Transact-SQL, AdventureWorks sample database


Before running this sample, make sure that SQL Server is installed, including the following components:
  • SQL Server Database Engine
  • SQL Server Management Studio
  • AdventureWorks SP1 sample database
  • Database Engine Samples
  • The AdventureWorks CLR sample. By default, this is placed in C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Programmability\CLR\AdventureWorks when you install Database Engine Samples. See the readme file for this sample for additional installation instructions.
  • .NET Framework SDK 2.0 or Microsoft Visual Studio 2005. You can obtain .NET Framework SDK free of charge. See Installing the .NET Framework Documentation.

Building the Sample

If you have not already created a strong name key file, generate the key file using the following instructions.
To generate a strong name key file
  1. Open a Microsoft Visual Studio 2005 command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.-- or --Open a Microsoft .NET Framework command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.
  2. Use the change directory command (CD) to change the current directory of the command prompt window to the folder where the samples are installed. Note: To determine the folder where samples are located, click the Start* button, point to All Programs, point to Microsoft SQL Server, point to Documentation and Tutorials, and then click Samples Directory. If the default installation location was used, the samples are located in <system_drive>:\Program Files\Microsoft SQL Server\100\Samples.*
  3. At the command prompt, run the following command to generate the key file: sn -k SampleKey.snk
  4. For this sample, you must get another key file: sn -k UnsafeSampleKey.snk Important: For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.
To build the sample, do the following:
Step 1: Install the sample and configure IIS
  1. Alter the permissions of the folder where this sample is installed so it may be accessed by the user under which IIS runs. See the default installation directory above for the location of this folder. By default IIS runs under machinename\ASPNET for IIS 5.1 (Windows XP) and Network Service for IIS 6.0 (Windows 2003).
  2. If you intend to compile by using MSBuild instead of Visual Studio, create the StoreCSVS v-root if it does not already exist by performing the following steps:
Right-click the StoreCSVS folder in C:\Program Files\Microsoft SQL Server\100\Samples\Integrated Samples\Storefront\CS\ and select Properties.
  1. In the StoreCSVS Properties page, go to the Web Sharing tab and select Share this folder.
  2. On the Edit Alias page, make sure Read is selected as the default Access permission and Script is selected as the default Application permission, and then click OK.
  3. If you have not already enabled the Default.aspx page on this server, you can do so by performing the following steps:
  4. Open Internet Information Services (IIS) Manager and expand the local computer in the explorer in the left pane.
  5. Right-click StoreCSVS and click Properties. StoreCSVS should be listed under Default Web Site in Web Sites. If you have left IIS Manager open from a previous step, you might need to click Action and then click Refresh to see the newly added v-root.
  6. Ensure that the ASP.NET version selected for the StoreCSVS virtual directory is 2.0.xxxxx where xxxxx is the build version.
  7. On the StoreCSVS Properties page, click the Documents tab, and then select Enable default content page. If Default.aspx is not listed as a content page, click Add.
  8. On the Add Content page, type Default.aspx, click OK, and then click OK again.
Step 2: Build the sample
  1. In Visual Studio
  2. Open the CS\StoreCSVS.sln solution file.
  3. On the Build menu, click Rebuild Solution.
  4. If you do not have Visual Studio, you can use MSBuild, which is distributed with the .NET Framework SDK 2.0
  5. Open a .NET Framework SDK 2.0 command prompt window.
  6. Change the directory to the Storefront sample directory.
  7. Run this command: msbuild /property:configuration=debug CS\StoreCSVS.sln
Step 3: Configure SQL Server
  1. Install the Storefront sample stored procedures by running the AWStore.sql script file. You can do this either by using Management Studio or by using the sqlcmd utility. The script file is located in the Scripts directory.
  2. To run the script file by using Management Studio, on the File menu, click Open, locate the Scripts folder, select the AWStore.sql file, and then run the contents of the file.
  3. To run the script file by using the sqlcmd utility, at the command prompt, change the directory to the folder where the AWStore.sql file is located, and then run the following command: sqlcmd -E -I -i awstore.sql
Step 4: Enable the OLAP-based product upsell scenario
  1. Open the Analysis Services project in <drive>:\Program Files\Microsoft SQL Server\100\Tools\Samples\AdventureWorks Analysis Services Project\enterprise\Adventure Works.sln.
  2. Deploy the project.
  3. In Management Studio, click Connect in Object Explorer, and then click Analysis Server.
  4. Click Connect in the dialog box that appears.
  5. Right-click the new top level Analysis Server node that is displayed in the Object Explorer tree control. The node will be similar to COMPUTERNAME. In Analysis Services, the node will be similar to Domain\User.
  6. Click Properties.
  7. Click the Security page.
  8. Click Add.
  10. Click OK twice.

Running the Sample

To run the sample, do the following:
Step 1: Browse the Web site
  1. Open Internet Explorer and type http://localhost/storecsvs in the address bar. With this application, you can perform a variety of real-world Web application tasks, including the following:
  2. Browse the tree control of the product categories.
  3. Find out what products are offered and available.
  4. Register a fictitious user on the system, including adding fictitious demographic information.
  5. Add items to your shopping cart.
  6. Go through the checkout process.
  7. View previously completed orders using the account icon.
  8. Use the Services icon to browse Web services, or the Search text box to find products.
Step 2: Modify the installed sample and recompile (Optional)
  1. Remove the reference to the StoreClientComponents DLL and PDB files from the bin folder for the Web site.
  2. Add the reference to the StoreClientComponents DLL by selecting the Web site project, and then using the Web Site/References menu item.
  3. Save the project.
  4. Delete the StoreCSVS folder and its contents from the Temporary ASP.NET Files folder by using the following procedure:
  5. Exit Visual Studio 2005.
  6. Stop IIS.
  7. Delete the StoreCSVS folder from the drive:\WINNT\Microsoft.NET\Framework\v2.0.xxxxx\Temporary ASP.NET Files folder.
  8. Empty the Recycle Bin.
  9. Start IIS. It is not necessary to recompile the sample to run it.

Removing the Sample

To remove the sample, do the following:
Remove the sample
  1. Open the Scripts\cleanup.sql file in Management Studio and run the contents of the file.


The common language runtime for SQL Server must be enabled for this sample to run correctly.

See Also

SQL Server End-to-End Samples
Help and Information
  • Getting SQL Server 2008 Assistance* © 2008 Microsoft Corporation. All rights reserved.

Last edited Mar 19, 2009 at 6:42 AM by cmslydia, version 21


edisonfung Jul 23, 2009 at 8:38 AM 
After install everything. Access Denis in IE

[HostingEnvironmentException: 無法存取 IIS Metabase。]
System.Web.Configuration.MetabaseServerConfig.MapPathCaching(String siteID, VirtualPath path) +637
System.Web.Configuration.MetabaseServerConfig.System.Web.Configuration.IConfigMapPath2.MapPath(String siteID, VirtualPath vpath) +9
System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) +174
System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath, Boolean permitNull) +51
System.Web.CachedPathData.GetConfigPathData(String configPath) +341
System.Web.CachedPathData.GetConfigPathData(String configPath) +234
System.Web.CachedPathData.GetApplicationPathData() +38
System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp) +8801967
System.Web.Configuration.RuntimeConfig.GetLKGRuntimeConfig(VirtualPath path) +117

emerald77 Nov 25, 2008 at 3:05 AM 
While attempting to perform "Step 3: Configure SQL Server", I received the following error message: "Execution of user code in the .NET Framework is disabled. Enable "clr enabled" configuration option." To enable CLR integration in SQL Server 2008, create and execute the following new query:

sp_configure 'show advanced options', 1;
sp_configure 'clr enabled', 1;

emerald77 Nov 25, 2008 at 2:44 AM 
After successfully performing all the steps on this Readme page, when I attempt to run the sample, I receive the following compiler error message in IE: "CS0246: The type or namespace name 'OrderDetails' could not be found (are you missing a using directive or an assembly reference?)". Any ideas on how to fix the problem? Thanks.