Export (0) Print
Expand All

Sales Orders Sample for Devices

SQL Server 2005

New: 14 April 2006

This sample is the mobile device version of the Sales Orders Sample for Merge Replication. This sample highlights using Microsoft SQL Server Compact Edition (SQL Server 2005 Compact Edition) as a Subscriber in a merge replication topology for delivering data to mobile device users. It also demonstrates the programmability features of replication in SQL Server 2005 Compact Edition. 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. The publication used by this sample is created when you install the Sales Orders Sample for Merge Replication. For more information about the replication scenario used in this sample, see Sales Orders Sample Scenario.

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

  • .NET Framework SDK 2.0 or Microsoft Visual Studio 2005 Service Pack 1 (SP1) or later versions. For more information, see Installing the .NET Framework SDK.
  • Microsoft SQL Server Compact Edition (SQL Server 2005 Compact Edition).
  • Microsoft ActiveSync 4.0 or later versions.
  • SQL Server 2005 Service Pack 2 (SP2) or later versions.
  • The SQL Server 2005 samples. These samples are included with SQL Server 2005 and are also available at the SQL Server Developer Center. For more information, see Installing Samples.

You must also have either a mobile device or a mobile device emulator (included with Microsoft Visual Studio 2005) with at least 15 MB of free memory on which to deploy and run the sample.

To initialize the subscription and download sales order data to the device, you must have a SQL Server 2005 Publisher configured to run the Sales Orders Sample for Merge Replication.

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

  • To run InstallSalesOrdersSample.bat at the Publisher, your Windows account must be a member of the sysadmin fixed server role at the Publisher. This batch file configures replication, creates the AdvWorksSalesOrders publication, and generates the initial snapshot.
  • To initialize the subscription and synchronize data with the Publisher, the Windows account used to connect to the Web server must meet the following requirements:
    • Have a valid login at the Publisher associated with a user in the publication database.
    • Have a valid login at the Distributor associated with a user in the distribution database (or the guest user).
    • Be a member of the publication access list (PAL) for the AdvWorksSalesOrders publication.
    ms365205.note(en-US,SQL.90).gifNote:
    When you use an anonymous connection to the Web server, the IIS anonymous Windows account is used to connect to the Publisher.

  • To connect to the Web server using Secure Sockets Layer (SSL) encryption, you must have a copy of the root certificate of the server certificate used to secure the Web server installed as a root certificate on the device. If the Web server is configured to require client certificates, you must also have a valid certificate installed as a personal certificate on the device.

To configure the replication topology and build and deploy the sample project:

  1. At the Publisher, run the publication installation script from the Sales Orders sample.
  2. Build the Sales Orders sample and deploy the business logic handler assembly on the Web server.
  3. Run the Configure Web Synchronization wizard to configure the virtual directory.
  4. Build and deploy the sample to a device or device emulator using Visual Studio 2005.

  1. On a computer that is running SQL Server 2005, execute the installation script from the Sales Orders Sample for Merge Replication to create the AdvWorksSalesOrders publication at the Publisher.

    ms365205.note(en-US,SQL.90).gifNote:
    The Sales Orders sample configuration script configures Web synchronization only for SQL Server 2005 and SQL Server Express Subscribers.

  2. At the command prompt, navigate to the SQL Server 2005 samples installation directory. The default is C:\Program Files\Microsoft SQL Server\90\Samples.

  3. Execute the following at a .NET Framework or Microsoft Visual Studio 2005 command prompt:

    sn -k SampleKey.snk

    ms365205.note(en-US,SQL.90).gifNote:
    You can skip this step if this key was previously created for use with another sample.

  4. Navigate to the installation location for the Sales Orders sample solution in Microsoft Visual C#. The default is C:\Program Files\Microsoft SQL Server\90\Samples\Replication\Merge\SalesOrders\CS.

  5. Open the SalesOrders.sln solution file in Visual Studio 2005.

  6. Build the project.

  7. Place a copy of the BusinessLogic.dll assembly in the C:\Program Files\Microsoft SQL Server\90\COM directory on the Web server.

  8. Run the Configure Web synchronization Wizard to create a virtual directory name "SalesOrdersMobile." For information about how to run this wizard, follow the steps in the How to: Configure Connectivity with the Configure Web Synchronization Wizard topic in SQL Server 2005 Compact Edition Books Online.

    ms365205.note(en-US,SQL.90).gifNote:
    When client certificates are required to connect to the Web server, you must have a valid personal certificate installed on the device.

  9. If using an anonymous connection to the Web server, create a login at the Publisher for the Windows account used for anonymous access, create a user in the AdventureWorks database for this login, and add this user to the PAL for the AdvWorksSalesOrders publication. For more information, see How to: Manage Logins in the Publication Access List (SQL Server Management Studio).

  10. Navigate to the installation location for the Sales Orders Mobile device sample solution in Microsoft Visual C#. The default is C:\Program Files\Microsoft SQL Server\90\Samples\Replication\Merge\SalesOrdersMobile\CS.

  11. Open the SalesOrdersMobile.sln solution file in Visual Studio 2005.

  12. Connect the device or device emulator and start ActiveSync.

  13. Build and deploy the project to the device.

  1. Cradle the device and ensure that ActiveSync is running.

  2. To secure the connection to the Web server using SSL, export the root certificate of the server certificate used to secure the SalesOrdersMobile virtual directory (in DER encoded binary X.509 format), copy it to the device, and tap to install it as a root certificate on the device. When client certificates are required to connect to the Web server, you must also have a valid personal certificate installed on the device.

    ms365205.security(en-US,SQL.90).gifSecurity Note:
    If you use Basic Authentication to connect to the Web server, you should use SSL to encrypt the connection to the Web server. This protects the Windows credentials.

  3. On the device, start Internet Explorer and browse to one of the following URLs:

    • http://webserver/SalesOrdersMobile/sqlcesa30.dll?diag - when using anonymous access to the Web server.
    • https://webserver/SalesOrdersMobile/sqlcesa30.dll?diag - when connecting to the Web server using SSL and specifying a Windows login and password to use for Basic Authentication.
  4. On the device or device emulator, start the SalesOrdersMobile program. When run for the first time, the program creates the SQL Server 2005 Compact Edition subscription database (\My Documents\AWMobile.sdf).

  5. On the Settings page, enter the name of the Publisher and the URL of the Web server in one of the following formats:

    • http://webserver/SalesOrdersMobile/sqlcesa30.dll. This URL is used when the Connect anonymously to server box is checked.
    • https://webserver/SalesOrdersMobile/sqlcesa30.dll. This URL is used when the Connect anonymously to server box is unchecked. You must also specify a Windows login and password in the Windows login and Password fields, where these values are the credentials that correspond to a Windows login at the Publisher and Distributor.
  6. Tap Save to save these settings.

  7. On the Synchronize page, verify the value in the Hostname field, select Full (recommended) for Sync type, and then tap Synchronize. The device connects to the specified Web server to create, initialize, and download subscription data for the application.

  1. With the subscription initialized, on the File menu, tap View Orders, and select a customer from the Customers list.

  2. To update an existing order, tap on an existing order in the Orders table, then do one of the following:

    • To update an existing item, double-tap an item in the Order Items grid, change the Quantity value for the selected item, and then tap Save.
    • To add a new item to the order, tap Add New, select the product from the Category and Product lists, set the order quantity in the Quantity field, and then tap Save.
    • To delete an existing item from an order, select the item in the Order Items grid, and then tap Delete.
  3. Tap Synchronize from the Tools menu, select either Full (recommended) or Upload only from the Sync type list, and then tap Synchronize.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft