The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Programming SQL CE Merge/Replication

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic    
Flat View: This topic has 0 replies on 1 page
Doug Thews

Posts: 866
Nickname: dougthews
Registered: Jul, 2003

Doug Thews is a software developer/manager for D&D Consulting Services with 18+ years of experience
Programming SQL CE Merge/Replication Posted: Jul 9, 2003 7:54 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Doug Thews.
Original Post: Programming SQL CE Merge/Replication
Feed Title: IlluminatiLand
Feed URL: http://apps5.oingo.com/apps/domainpark/domainpark.cgi?client=netw8744&s=JETBRAINS.COM
Feed Description: A technology blog for people enlightened enough to think for themselves
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Doug Thews
Latest Posts From IlluminatiLand

Advertisement
Configuring a SQL Server database for Merge/Replication is the hardest part of developing a solution. Here's the snippet of code you'll need to perform Merge/Replication with the SQL Merge Agent. Notice that the only thing to consider is whether to create the local database or use the existing one. Imports System.Data.SqlServerCe Imports System.Data.SqlServerCe.SqlCeException Dim oRepl As New SqlCeReplication ' Set the values for the CE replication object oRepl.Publisher = "(SQL Server Name)" oRepl.PublisherDatabase = "(Publication Database)" oRepl.Publication = "(Publication Name)" oRepl.PublisherLogin = "(Publisher Login)" oRepl.PublisherPassword = "(Publisher Password)" oRepl.SubscriberConnectionString = "(Local Conn. Str)" oRepl.Subscriber = "(Subscriber Name)" oRepl.InternetUrl = "(SQL CE IIS URL)" oRepl.InternetLogin = "(SQL CE IIS Login)" oRepl.InternetPassword = "(SQL CE IIS Password)" ' Make sure we get updates as well as send them oRepl.ExchangeType = ExchangeType.BiDirectional Try  ' If the local DB exists, then just synch to it,  If Not File.Exists("Local DB Filename.sdf") Then   ' Tell SQL CE to create the database   oRepl.AddSubscription(AddOption.CreateDatabase)  End If  ' Now synchronize with the current snapshot  ' in Merge Replication  oRepl.Synchronize()  Catch ex As SqlCeException   'TODO: Error handling code here  End Try  ' Cleanup  oRepl.Dispose() Once you create the local database, you can then use the familiar objects like SqlCeConnection and SqlCeDataAdapter (just like their ADO.NET counterparts) to get your data into datatables and datasets so that you can work with them just like a WinForms (or ASP.NET) application. You'll want to insert error handling in the area specified, but hopefully what you gain from this is that there is not that much additional coding overhead to use erge/Replication to create disconnected database applications on the CF.NET framework. (* re-posted for formatting)

Read: Programming SQL CE Merge/Replication

Topic: Rockets on Prisoner Award Previous Topic    

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use