Free Newsletters:
DatabaseJournal  
DBANews
Search Database Journal:
 
HOME News MS SQL Oracle DB2 Access MySQL PostgreSQL PHP SQL Etc Scripts Links Discussion
internet.com

» HOME
» NEWS
» FEATURES
» SERIES
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Products
Scripts
Links
» DISCUSSION
» TECH JOBS

Marketplace Partners
Be a Marketplace Partner




internet.commerce
Be a Commerce Partner
Promos and Premiums
Phone Cards
Prepaid Phone Card
Web Hosting Directory
Server Racks
Laptops
Hurricane Shutters
Memory
Promote Your Website
Desktop Computers
KVM Switches
Build a Server Rack
Corporate Gifts
Promotional Products




MySpace Joins eBay, Yahoo in Open Profile Push

News Corp. Unit Under Fire for Ties to Hacker

Are Non-PC Devices Hurting 'Net Innovation?

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Linked Data Planet Conference & Expo

CA ERwin® Data Modeler Proven database design and modeling. Efficiently analyze, design and deploy effective database solutions. Whitepaper: Manage SQL Server Deployments
Try it free: CA ERwin® Data Modeler

 

 
Download: Solaris 8 Migration Assistant
Rapidly move your Solaris 8 application environments to new systems running Solaris 10 with the Solaris 8 Migration Assistant. Reduce migration risk while taking advantage of increased performance, reliability and security of the latest SPARC hardware platforms and Solaris 10 OS. Click here »
 

 

Guide to Oracle 11g and Database Migration
Oracle Database 11g includes more features for self-management and automation, which makes it easier for customers to cost-effectively manage their data. Download this Internet.com eBook for an overview of some of the new features in 11g and for an overview of the issues you need to consider as you prepare for a database migration. »
Innovate Faster with Oracle Database 11g
Read this in-depth analysis of 56 customers, which shows significant differences between the value software vendors Oracle and SAP deliver to midsize companies. »
Oracle Business Intelligence Standard Edition One
Find out how Newport Beach, CA-based Mobilitie is shaking up the telecom industry by leveraging technology to provide an entirely different financial model for deploying, upgrading, and owning wireless and wireline network assets. »
Business Intelligence and Enterprise Performance Management: Trends for Emerging Businesses
Quickly implementing an ERP software solution can be of tremendous benefit; however, companies often struggle to balance the benefits of reducing implementation time and cost with the risks of an accelerated deployment. Read this white paper to learn about easy-to-follow best practices for achieving a successful accelerated implementation. »
Making the Case for Oracle Database on Windows
Users benefit as vendors reduce enterprise complexity and deliver integration. »
Related Articles
SQL Server 2005 Express Edition - Part 20 - Authenticating Merge Web Synchronization
SQL Server 2005 Express Edition - Part 19 - Authenticating Merge Web Synchronization
SQL Server 2005 Express Edition - Part 18 - Merge Web Synchronization Setup
SQL Server 2005 Express Edition - Part 10

Production Manager (hands on)
Aquent
US-MA-Cambridge

Justtechjobs.com Post A Job | Post A Resume
MS SQL
April 24, 2008
SQL Server 2005 Express Edition - Part 21 - Using Replication Management Objects
By Marcin Policht

In the most recent installments of our series covering new and improved features incorporated into SQL Server 2005 Express Edition, we have been discussing its replication characteristics. As we have pointed out, while there are some significant limitations in this area (when compared with its predecessor - SQL Server 2000 MSDE - as well as its full-fledged contemporaries), there are several workarounds that can be used to emulate missing functionality. So far, we have demonstrated this approach by taking advantage of replication-specific executables (such as distrib.exe or replmerg.exe) and T-SQL code combined with Windows Synchronization Manager and Web Synchronization technologies. In this article, we will explore another method of reaching the same goal, which involves Replication Management Objects (RMO).

In order to improve the ability to automate administration of its database management products, with the release of SQL Server 2000, Microsoft has introduced SQL Distributed Management Objects (SQL-DMO) - a COM-based object model, easily accessible through programming or scripting. With advent of SQL Server 2005, features available via SQL-DMO technology have been implemented as a set of .NET-based object libraries, with the bulk of administrative tasks packaged in the form of SQL Server Management Objects (SMO) and those specific to replication separated as Replication Management Objects (RMO). The latter has been encapsulated into Microsoft.SqlServer.Rmo.dll assembly, residing by default (alongside Microsoft.SqlServer.Smo.dll and other supporting libraries) in the Program Files\Microsoft SQL Server\90\SDK\Assemblies folder, created during the setup of SQL Server 2005 Express Edition (providing that you specified that Replication component should be included in the installation).

To leverage capabilities exposed through the RMO, you can use Visual Basic 2005 Express Edition (for more information regarding location of its source files, its licensing model, or setup, refer to an earlier article of this series). Once you have it installed and running, launch a new project (by using the appropriate entry from the top level File menu) based on the Console Application template. To access classes built into Replication Management Objects, you need to make your project aware of their respective libraries. The simplest way to accomplish this involves the use of the Add Reference dialog box (invoked via the context sensitive menu of the References node in the Solution Explorer window of Visual Basic 2005 Express Edition interface). From its .NET tab, choose Microsoft.SqlServer.Replication .NET Programming Interface, Microsoft.SqlServer.ConnectionInfo, and Replication Agent Library items and click on the OK command button to confirm your selection. At that point, you should be able to add relevant code to the default Module1 that is automatically generated as part of your project. In our sample demonstration, we will leverage code listed in the How to: Synchronize a Pull Subscription (RMO Programming) article of the SQL Server 2005 Books Online, but will simplify it for the sake of clarity, by retaining only those sections that provide core configuration settings or actions necessary to perform synchronization and removing its error checking provisions. (Obviously, you should add missing code before deploying such a solution in your production environment). The first portion of the code (which allows us to reference all members of relevant namespaces directly by their name - rather than being forced to specify it in the fully qualified format) needs to be part of the (General) (Declarations) section of the Module1.vb (we will rely on VB.NET programming language throughout our example):

Imports Microsoft.SqlServer.Replication
Imports Microsoft.SqlServer.Management.Common

while the second portion will constitute the content of its Main() subroutine. Note that we follow the same naming convention and assumptions that were used in our earlier examples, utilizing replmerg.exe command line utility, i.e. our publication based on the SalesTaxRate(Sales) table in AdventureWorks database exists on the distributor/publisher located on the default SQL Server 2005 Enterprise Edition instance hosted on the computer ALPHA, and our SQL Server 2005 Express Edition-based subscription database called AdventureWorksRepl resides on computer OMEGA, with properly configured subscription. The code below is also based on the premise that the subscription has been assigned correct Security and Web Synchronization settings, including working Windows integrated authentication-based connections to its distributor/publisher and the Web Server, as well as a URL pointing to the WebSync virtual directory. (Reference the SQL Server 2005 Books Online article we mentioned above if any of these assumptions do not apply in your case and you need to set some of configuration parameters through code). With these simplifications in place, the resulting module takes the following form:

Module Module1
 
    Sub Main()
 
        Dim subscriberName As String = "OMEGA\SQLEXPRESS"
        Dim publisherName As String = "ALPHA"
        Dim publicationName As String = "SalesTaxRate(Sales)"
        Dim subscriptionDbName As String = "AdventureWorksRepl"
        Dim publicationDbName As String = "AdventureWorks"
 
        Dim conn As ServerConnection = New ServerConnection(subscriberName)
 
        Dim subscription As MergePullSubscription
        Dim agent As MergeSynchronizationAgent
 
        conn.Connect()
 
        subscription = New MergePullSubscription()
        subscription.ConnectionContext = conn
        subscription.DatabaseName = subscriptionDbName
        subscription.PublisherName = publisherName
        subscription.PublicationDBName = publicationDbName
        subscription.PublicationName = publicationName
 
        subscription.LoadProperties()
 
        agent = subscription.SynchronizationAgent
 
        agent.OutputVerboseLevel = 1
        agent.Output = ""
 
        agent.Synchronize()
 
        conn.Disconnect()
 
    End Sub
 
End Module

By establishing an instance of ServerConnection class and invoking its Connect() method, we obtain access to the subscriber. LoadProperties() method of the MergePullSubscription class retrieves properties of our preconfigured subscription, which are necessary to initiate synchronization. Thanks to having the appropriate values assigned to Output and OutputVerboseLevel properties of the instance of SynchronizationAgent class, we are able to view status messages displayed during Web synchronization (in the same manner, in which they are displayed when running replmerge.exe from the Command Prompt). You can track execution of the module using options available via the top level Debug menu or by running an executable generated via Build menu from the Command Prompt. Note that with RMO programming, you can manage a variety of replication activities (beyond pull merge Web Synchronization covered in our example). For more information, refer to the Programming with Replication Management Objects article in the SQL Server 2005 Books Online.

This concludes our discussion regarding replication functionality in SQL Server 2005 Express Edition. In our next article, we will start exploring several of its most common upgrade scenarios.

» See All Articles by Columnist Marcin Policht

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MS SQL Archives

IT in 2018: Download Free eBook By The Author Of "Does IT Matter?" Simple Registration Is Required.
Download: SQL Compare Pro 6--The fastest, easiest way to compare and synchronize two databases.
Five Trends for Application Development. Download Your Complimentary Report. Exclusive. Act Now.
Download: SQL Backup & DBA Best Practices eBook
HP eBook: Using Business Service Management (BSM) to Manage Your Business Applications


Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
How To Transfer Access Data Records To SQL ?? ankurdjariwala 1 May 8th, 12:24 PM
problem with federated server linking majidkhan 1 April 29th, 10:00 AM
"SELECT rowguidcol" from tables on linked servers? brentbordelon 1 April 25th, 04:12 PM
"SELECT rowguidcol" vs. "SELECT <actual name>" rgarrison 9 April 16th, 03:46 PM







JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES