Sales Orders Sample for Merge Replication

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

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.
This readme file details how to install and run the Sales Orders sample. This file also details any known issues with the sample.

Scenario

This sample highlights a merge replication topology for delivering data to mobile users, and it also demonstrates the programmability features of merge replication in SQL Server. The sample is a Windows Forms-based application that uses standard Microsoft data access technologies and merge replication to enable a salesperson to maintain her own local data while synchronizing periodically with the home office. This sample is supported for Subscribers running all editions of SQL Server. The publication also supports SQL Server Compact 3.5 Subscribers. For more information about this sample scenario, see Sales Orders Sample Scenario.

Languages

Features

The Sales Orders sample demonstrates the following features of merge replication:

Prerequisites

Before running this sample, make sure the following software is installed:

Required Permissions

The permissions needed to configure and run the Sales Orders sample are based on replication security requirements, and are as follows:

Building and Configuring the Sample

To build the sample project and configure the replication topology, you will need to do the following:
To configure the Sales Orders sample at the Publisher
  1. Ensure that the AdventureWorks sample database has been installed and the database is attached. If the database is not attached, see Installing AdventureWorks Sample Databases and Samples in SQL Server Books Online.
  2. Ensure that the SQL Server Database Engine samples have been installed.For more information, see Installing SQL Server Samples and Sample Databases.
  3. Ensure that SQL Server Agent is running. You can view the status of and start this service from Object Explorer in SQL Server Management Studio.
  4. Navigate to the installation location for the Sales Order sample scripts. The default is C:\Program Files\Microsoft SQL Server\100\Samples\Replication\Merge\SalesOrders\Scripts.
  5. (Optional) Configure Secure Sockets Layer (SSL) at the Publisher or at the server used for Web synchronization. SSL is required for communication between the IIS server and all Subscribers. To configure SSL, specify a server certificate for the IIS server to use.
  6. Execute InstallSalesOrdersSample.bat and when prompted enter the login (in the case-sensitive format "DOMAIN\login") and password for the Windows account under which the Snapshot Agent job will run. This calls sqlcmd.exe to execute CreateAdvWorksSalesOrdersPublication.sql, which does the following:
  7. Checks that replication has been configured on the local server, and if not configures it as a Publisher with local Distributor using the distribution database.
  8. Drops and re-creates the stored procedures and user-defined functions used for data access at the client.
  9. Drops and re-creates the AdvWorksSalesOrders Publication.
  10. Adds articles to the publication.
  11. Registers the business logic handler at the Distributor.
  12. Starts the Snapshot Agent job to generate the initial snapshot. The batch file can also automatically configure a virtual directory at the Publisher to support Web synchronization. If you choose not configure the virtual directory at the Publisher during installation, or if you plan to use a separate Web server, you must run the Configure Web Synchronization Wizard prior to using the Web synchronization features of the sample.
  13. (Optional) Run the Configure Web Synchronization Wizard to configure an IIS server to support Web synchronization. Skip this step if InstallSalesOrdersSample.bat successfully created the virtual directory or if you will not use Web synchronization. For complete instructions about using this wizard, see How to: Configure an IIS Server for Web Synchronization (SQL Server Management Studio).
  14. Before continuing, ensure that the Snapshot Agent job for the AdvWorksSalesOrders publication has successfully completed. The status of this job can be viewed using Replication Monitor. For information about using Replication Monitor to view the status of a Snapshot Agent job, see the topic How to: View Information and Perform Tasks for the Agents Associated With a Publication (Replication Monitor) in SQL Server Books Online.
To build and configure the Sales Orders sample at the Subscriber
  1. At the command prompt, navigate to the SQL Server samples installation directory. The default is C:\Program Files\Microsoft SQL Server\100\Samples\.
  2. Execute the following at a .NET Framework or Microsoft Visual Studio 2005 command prompt: sn -k SampleKey.snk Note: You can skip this step if this key was previously created for use with another sample.
  3. Navigate to the installation location for the Sales Orders sample solution in Microsoft Visual C#. The default is C:\Program Files\Microsoft SQL Server\100\Samples\Replication\Merge\SalesOrders\CS.
  4. Open the SalesOrders.sln solution file in Visual Studio 2005.
  5. Build the project.
  6. In the project output folder, edit the SalesOrders.exe.config file and change the following:
  7. Replace the value of the Subscriber key with the name of the local server.
  8. Replace the value of the Publisher key with the name of the server configured previously as the Publisher.
  9. (Optional) Replace the value of the WebSynchronizationUrl key when connecting to the Publisher using Web synchronization. This can also be done at run time.
  10. (Optional) Use the SyncWhenConnectedInterval key to set the interval between synchronizations, in seconds, when using the synchronize-when-connected functionality. Note: Replication does not support localhost for server names.
  11. Place a copy of the BusinessLogic.dll assembly in the