Export (0) Print
Expand All

Replication ActiveX Controls Sample

SQL Server 2005

New: 5 December 2005

This readme file details how to install and run the Replication ActiveX Controls Sample.

This sample demonstrates how to include the SQL Distribution and SQL Merge controls in a custom application. This sample uses a single instance of Microsoft SQL Server 2005 for the Publisher, Distributor, and Subscriber. In this case, the SQL Distribution control and SQL Merge control run at the Distributor. The sample contains two separate sample projects: a Microsoft Visual C++ 6.0 console application and a Microsoft Visual Basic 6.0 forms-based application. Each project demonstrates both the SQL Distribution control and the SQL Merge control. The sample also demonstrates how to use the callback functionality of the controls to monitor synchronization status. The Visual Basic 6.0 application also enables you to change subscription properties.

ms345272.note(en-US,SQL.90).gifNote:
For a managed-code application, use the TransSynchronizationAgent and MergeSynchronizationAgent classes in the Microsoft.SqlServer.Replication namespace. For more information, see Planning for Replication Programming.

  • Microsoft Visual Basic 6.0
  • Microsoft Visual C++ 6.0
  • Transact-SQL

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

  • SQL Server 2005, including the following optionally installed components:
    • Database Services (including replication).
    • Client Connectivity Components.
    • Software Development Kit (SDK).
    • AdventureWorks Sample OLTP Database. This sample database is included with SQL Server 2005 and is also available at the SQL Server Developer Center.
    • 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.
    • Visual Studio 6.0, Visual Basic 6.0, or Visual C++ 6.0.
    ms345272.note(en-US,SQL.90).gifNote:
    This sample is not supported on 64-bit (IA64) platforms.

The Replication ActiveX Controls sample uses Windows Authentication. The permissions needed to configure and run the sample are based on replication security requirements, and are as follows:

  • To run InstallReplicationControlSample.bat, which creates a replication working share, configures replication, creates the publications, and generates the initial snapshots, your Windows account must be a member of the sysadmin fixed server role.
  • To start the SQL Distribution control or SQL Merge control to synchronize the sample subscriptions, your Windows account must be a member of the db_owner fixed database role in the distribution and subscription databases.

To build the sample project and configure the replication topology, do the following:

  • Run the replication installation script.
  • Build the Visual Basic or Visual C++ version of the sample using Visual Studio 6.0, Visual Basic 6.0, or Visual C++ 6.0.
To configure the Replication Controls sample
  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 most recent version of the SQL Server Database Engine samples has been installed. For more information, see Downloading and Updating Books Online in SQL Server Books Online.

  3. Ensure that SQL Server Agent is running. You can view the status of this service, and start the service, from Object Explorer in SQL Server Management Studio.

  4. Navigate to the installation location for the Replication ActiveX Controls sample scripts. The default is C:\Program Files\Microsoft SQL Server\90\Samples\Replication\ActiveX\Scripts.

  5. Execute InstallReplicationControlSample.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 runs. This calls sqlcmd.exe to execute CreateReplicationControlPublications.sql, which does the following:

    • 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.
    • Drops and re-creates the sample publications.
    • Adds articles to the publications.
    • Starts the Snapshot Agent jobs to generate the initial snapshots for the publications.
    • Creates and registers subscriptions to the publications.
To build the Replication ActiveX Controls sample using Visual C++ 6.0
  1. Open Visual C++ 6.0. On the main menu, click File, click Open Workspace, navigate to the location of the C++ project files (the default is C:\Program Files\Microsoft SQL Server\90\Samples\Replication\ActiveX\CPP6 directory), and then open distsamp.dsw.

  2. On the Directories tab, in the Show directories for drop-down list, click Library files, and then add the path C:\Program Files\Microsoft SQL Server\90\COM. This path assumes SQL Server 2005 was installed to the default directory.

  3. On the Build menu, click Build distsamp.exe. The default location of the resulting distsamp.exe is in C:\Program Files\Microsoft SQL Server\90\Samples\Replication\ActiveX\CPP6\Debug or C:\Program Files\Microsoft SQL Server\90\Samples\Replication\ActiveX\CPP6\Release, depending on the build configuration.

  4. Repeat steps 1 through 3 to build mergsamp.exe.

To build the Replication ActiveX Controls sample using Visual Basic 6.0
  1. Start Visual Basic 6.0. On the main menu, click File, click Open Project, navigate to the C:\Program Files\Microsoft SQL Server\90\Samples\Replication\ActiveX\VB6 directory, and then open replsamp.vbp.

  2. On the Project menu, click References, and then under Available references, ensure that the following references are enabled:

    • Microsoft SQL Distribution Control 9.0
    • Microsoft SQL Merge Control 9.0
    • Microsoft SQL Replication Errors 9.0
  3. On the File menu, click Make ReplSamp.exe. The default location of the resulting ReplSamp.exe is in C:\Program Files\Microsoft SQL Server\90\Samples\Replication\ActiveX\VB6.

To use the sample, you must navigate to the location of the built executables, and run the executables.

To run the Visual C++ 6.0 version of the Replication ActiveX Controls sample
  1. Navigate to the build location for the Visual C++ 6.0 version of the Replication ActiveX Controls sample. The default is C:\Program Files\Microsoft SQL Server\90\Samples\Replication\ActiveX\CPP6\Debug.

  2. Run distsamp.exe to start the Distribution Agent to synchronize the pull subscription to the transactional publication, and run mergsamp.exe to synchronize the pull subscription to the merge publication.

To run the Visual Basic 6.0 version of the Replication ActiveX Controls sample
  1. Navigate to the build location for the Visual Basic 6.0 version of the Replication ActiveX Controls sample. The default is C:\Program Files\Microsoft SQL Server\90\Samples\Replication\ActiveX\VB6.

  2. Run ReplSamp.exe.

  3. On the Replication Controls ActiveX Sample form, select Transactional or Merge from the Publication type drop-down list, and click Get Subscription Properties. This loads the properties of the selected subscription.

  4. (Optional) This application can be used to synchronize any other pull subscription on the local machine. Click Edit to change the subscription properties, and then click Update when finished.

  5. Click Synchronize to synchronize the subscription.

  6. (Optional) To run a quick synchronization of one of the default subscriptions, click Transactional or Merge from the Synchronize menu.

Use the following procedure to remove the Replication ActiveX Controls sample.

To remove the Replication ActiveX Controls sample
  1. Navigate to the installation location for the Replication ActiveX Controls sample scripts. The default is C:\Program Files\Microsoft SQL Server\90\Samples\Replication\ActiveX\Scripts.

  2. Execute the batch file RemoveReplicationControlSample.bat.

  3. When prompted, type "Y" and press Enter to remove all replication objects at the Publisher, remove all replication objects in the subscription database, and uninstall publishing and distribution at the Publisher.

    ms345272.note(en-US,SQL.90).gifImportant:
    This script removes all replication infrastructure. If you have created other publications that use this Publisher or Distributor, do not execute RemoveReplicationControlSample.bat. Instead, you should remove the sample publications manually. For more information, see How to: Delete a Publication (SQL Server Management Studio) or How to: Delete a Publication (Replication Transact-SQL Programming) in SQL Server Books Online.

  4. On the AdventureWorksLocal database, execute sp_removedbreplication.

  5. Change the database context to the master database and execute DROP DATABASE AdventureWorksLocal.

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. 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.

Release History

14 April 2006

New content:
  • Added a note that states that this sample is not supported on 64-bit (IA64) platforms.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft