The XmlSurvey sample application collects information for a store survey and updates the SQL Server AdventureWorks database with the results. Stores in the database represent resellers. The survey is stored as XML in the Demographics column of the Sales.Store table.
To keep the application simple, the record with a Customer ID of 1 is updated to contain the specified XML each time a survey is saved.
| Note: |
|---|
| CustomerID is the primary key in the Sales.Store table and a foreign key in the Sales.Customer table. |
The default installation directory is drive:\Program Files\Microsoft SQL Server\90\Samples\Engine\XML\XmlSurvey.
Scenario
A developer wants to create an application that updates store demographics information by sending an XML document to a Web service hosted by SQL Server.
Languages
Transact-SQL, XML, XSD, Visual C#, and Visual Basic.
Features
The XmlSurvey sample uses the following features of SQL Server 2005.
| Application Area | Features |
|---|---|
|
Overall |
XML, SQL Server-hosted Web services |
Prerequisites
Before running this sample, make sure the following software is installed:
-
SQL Server 2005, including the following components:
-
SQL Server Database Engine
-
SQL Server Management Studio
-
AdventureWorks sample database
-
Database Engine Samples
-
.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.
-
SQL Server Database Engine
Building the Sample
To build the sample, do the following:
Build the sample
-
Ensure that the AdventureWorks sample database is installed.
-
In SQL Server Management Studio, load and execute the Scripts\InstallCS.sql script to create the following :
-
SaveStoreSurvey stored procedure
-
sql_StoreSurvey HTTP Endpoint
-
SaveStoreSurvey stored procedure
-
CD to the install directory and execute the following at a .NET Framework or Microsoft Visual Studio 2005 command prompt:
sn -k keypair.snk -
Build the sample using the solution provided and Visual Studio, or execute the following at the command prompt:
Running the Sample
To run the sample, do the following:
Run the sample
-
Execute CS\XmlSurvey\bin\debug\XmlSurvey.exe.
-
Fill in the survey.
-
Save the survey by clicking Save on the File menu.
-
Verify that the Sales.Store table has been updated by executing a query similar to the following and then clicking on the data in the Demographics column in the results pane:
SELECT * FROM Sales.Store WHERE CustomerID = 1
Removing the Sample
To remove the sample, do the following:
Remove the sample
-
Open the Scripts\Cleanup.sql file using SQL Server Management Studio and execute the contents of the file.