The Storefront sample for the Adventure Works Cycles sample database in SQL Server 2005 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 2005 version of the sample application.
This sample works with the AdventureWorks sample database, which is included with SQL Server 2005. 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 drive:\Program Files\Microsoft SQL Server\90\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 2005:
Common language runtime user-defined function, common language runtime user-defined type
ADO.NET, Transact-SQL, AdventureWorks sample database
Before running this sample, make sure that SQL Server 2005 SP1 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\90\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 SDK.
Building the Sample
If you have not already created the strong-name key files SampleKey.snk and UnsafeSampleKey.snk, generate the key files by using the following procedure.
To generate a strong name key file
Open a Microsoft Visual Studio 2005 command prompt. Click Start, point to All Programs, point to Microsoft Visual Studio 2005, point to Visual Studio Tools, and then click Visual Studio 2005 Command Prompt.
Open a .NET Framework command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.
At the command prompt, use the change directory (CD) command to change the current folder of the command prompt window to the Samples folder.
To determine the folder where samples are located, click Start, point to All Programs, point to Microsoft SQL Server 2005, 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\90\Samples.
At the command prompt, run the following commands to generate the key files:
sn -k SampleKey.snk
sn -k UnsafeSampleKey.snk
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
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).
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 drive:\Program Files\Microsoft SQL Server\90\Samples\Integrated Samples\Storefront\CS\ and select Properties.
- In the StoreCSVS Properties page, go to the Web Sharing tab and select Share this folder.
- 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.
If you have not already enabled the Default.aspx page on this server, you can do so by performing the following steps:
- Open Internet Information Services (IIS) Manager and expand the local computer in the explorer in the left pane.
- 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.
- Ensure that the ASP.NET version selected for the StoreCSVS virtual directory is 2.0.xxxxx where xxxxx is the build version.
- 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.
- On the Add Content page, type Default.aspx, click OK, and then click OK again.
Step 2: Build the sample
In Visual Studio
- Open the CS\StoreCSVS.sln solution file.
- On the Build menu, click Rebuild Solution.
If you do not have Visual Studio, you can use MSBuild, which is distributed with the .NET Framework SDK 2.0
- Open a .NET Framework SDK 2.0 command prompt window.
- Change the directory to the Storefront sample directory.
- Run this command:
msbuild /property:configuration=debug CS\StoreCSVS.sln
Step 3: Configure SQL Server
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.
- 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.
- 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
Open the Analysis Services project in drive:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks Analysis Services Project\Adventure Works.sln.
Deploy the project.
In Management Studio, click Connect in Object Explorer, and then click Analysis Server.
Click Connect in the dialog box that appears.
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 Microsoft Analysis Server 9.0, the node will be similar to Domain\User.
Click the Security page.
Click OK twice.
Running the Sample
To run the sample, do the following:
Step 1: Browse the Web site
Open Internet Explorer and type
http://localhost/storecsvsin the address bar. With this application, you can perform a variety of real-world Web application tasks, including the following:
- Browse the tree control of the product categories.
- Find out what products are offered and available.
- Register a fictitious user on the system, including adding fictitious demographic information.
- Add items to your shopping cart.
- Go through the checkout process.
- View previously completed orders using the account icon.
- 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)
Remove the reference to the StoreClientComponents DLL and PDB files from the bin folder for the Web site.
Add the reference to the StoreClientComponents DLL by selecting the Web site project, and then using the Web Site/References menu item.
Save the project.
Delete the StoreCSVS folder and its contents from the Temporary ASP.NET Files folder by using the following procedure:
- Exit Visual Studio 2005.
- Stop IIS.
- Delete the StoreCSVS folder from the drive:\WINNT\Microsoft.NET\Framework\v2.0.xxxxx\Temporary ASP.NET Files folder.
- Empty the Recycle Bin.
- 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
- Open the Scripts\cleanup.sql file in Management Studio and run the contents of the file.
The common language runtime for SQL Server 2005 must be enabled for this sample to run correctly.
Help and Information
5 December 2005
14 April 2006