Readme_XmlSurvey Sample

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 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 C:\Program Files\Microsoft SQL Server\100\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 that is 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.

Application Area Features
Overall XML, SQL Server-hosted Web services


Prerequisites

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.
Before running this sample, make sure SQL Server is installed, including the following components:
  • SQL Server Database Engine
  • SQL Server Management Studio
  • The AdventureWorks database that is available at the SQL Server Developer Web site.
  • The SQL Server Database Engine samples that is available at the SQL Server Developer Web site.
  • .NET Framework SDK 2.0 or Microsoft Visual Studio 2005. You can obtain .NET Framework SDK free of charge. For more information, 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 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.
Build the sample
  1. Ensure that the AdventureWorks sample database is installed.
  2. In SQL Server Management Studio, load and run the Scripts\InstallCS.sql script to create the following
  3. SaveStoreSurvey stored procedure
  4. sql_StoreSurvey HTTP Endpoint
  5. Build the sample by using the solution provided and Visual Studio, or run the following at a .NET Framework or Microsoft Visual Studio 2005 command prompt: * msbuild /nologo /verbosity:quiet /property:Configuration=Debug CS\XmlSurvey.sln *

Running the Sample

To run the sample, do the following:
Run the sample
  1. Run CS\XmlSurvey\bin\debug\XmlSurvey.exe.
  2. Fill in the survey.
  3. Save the survey by clicking Save on the File menu.
  4. Verify that the Sales.Store table has been updated by run a query similar to the following, and then selecting 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
  1. Open the Scripts\Cleanup.sql file by using Management Studio and execute the contents of the file.

Comments

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.

See Also

Concepts
XML Samples
Help and Information
  • Getting SQL Server 2008 Assistance* © 2008 Microsoft Corporation. All rights reserved.

Last edited Nov 6, 2008 at 11:58 PM by bonniefe, version 9

Comments

p_maroun Feb 10, 2010 at 11:25 PM 
i am trying to build this solution but it's not possible because when I run the "InstallCS.sql" script it generates an error:
Msg 7878, Level 16, State 1, Line 2
This "CREATE ENDPOINT" statement is not supported on this edition of SQL Server.
Msg 15063, Level 16, State 1, Line 1
The login already has an account under a different user name.
Cannot grant, deny, or revoke permissions to sa, dbo, entity owner, information_schema, sys, or yourself.


Can someone help?? I don't understand why they make samples for sql server 2008 when the script commands are deprecated.