Sync Services Part 1

by Administrator 26. January 2008 23:21

In this post we will create a local cache of the Northwind database.  To start with lets create a new visual basic windows forms project in Visual Studio 2008.  From the project menu select add a new item and select a new local database cache and name it northwind.

 

image

 

In the server connect select a connection to the northwind database.

 

Press the add button and select the product table.  Press OK to close the dialog.  Go ahead and create a table adapter for the product table.  The drag the products table on to the form from the data source window.  Add a button to the binding navigator and set its text to Sync and change the display style to Text.

 

In the button you added to the toolbar add this code

 

Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

       ' Update the database

        Me.ProductsBindingSource.EndEdit()         Me.TableAdapterManager.UpdateAll(Me.NorthwindDataSet)

        ' Call SyncAgent.Synchronize() to initiate the synchronization process.

        ' Synchronization only updates the local database, not your project’s data source.

        Dim syncAgent As ProductsSyncAgent = New ProductsSyncAgent()         Dim syncStats As Microsoft.Synchronization.Data.SyncStatistics = syncAgent.Synchronize()

       ' Reload the data source from the local database

        Me.ProductsTableAdapter.Fill(Me.NorthwindDataSet.Products)

End Sub

Run the app and Open up the Sql Server Management Studio Express.  Make some changes in the Northwind database's Product table and Press the sync button.  

 

Notice the changes you made to the Products table show up in the datagridview.  The changes are also saved in the local sqlce database.



kick it on DotNetKicks.com

Tags: , ,

Ado.Net | Sql | VB

Comments (5) -

busbyseotest
12/22/2008 3:59:15 AM #

this post is useful to know Visual Studio 2008. thanks

hrer
hrer
3/26/2010 8:23:35 AM #

http://hebe-blue.com/">hebe-blue
http://tennis-athletcs.com/">tennis-athletcs
http://sports-aquatics.com/">sports-aquatics
http://swimming-athletics.com/">swimming-athletics
http://sports-swimming.com/">sports-swimming
http://sports-freestyle.com/">sports-freestyle
http://sports-backstroke.com/">sports-backstroke
http://football-all.net/">football-all
http://sports-butterfly.com/">sports-butterfly
http://baseball-allin.com/">baseball-allincaca
http://sports-track.net/">sports-track
http://sports-jumping.com/">sports-jumping
http://sports-polevault.com/">sports-polevault
http://softball-into.com/">softball-into
http://sports-winston.com/">sports-winston

transcription company
transcription company
4/9/2010 10:35:17 AM #

Thank you a lot for such great release connecting with this good post !

Comments are closed

About the author

I work at seaworld as a software developer.  

 

Windows phones apps

 

Auto Codes

Points Calculator

Month List

Page List