DbServerSyncProvider Class
SQL Server 2005
Abstracts a generic server synchronization provider that communicates with the server database and shields the synchronization agent from the specific implementation of the database.
Namespace: Microsoft.Synchronization.Data.Server
Assembly: Microsoft.Synchronization.Data.Server (in microsoft.synchronization.data.server.dll)
Assembly: Microsoft.Synchronization.Data.Server (in microsoft.synchronization.data.server.dll)
The principal activities of the server synchronization provider are as follows:
-
Stores information about tables on the server that are enabled for synchronization.
-
Enables applications to retrieve changes that occurred in the server database since the last synchronization.
-
Applies incremental changes to the server database.
-
Detects conflicting changes.
System.Object
Microsoft.Synchronization.SyncProvider
Microsoft.Synchronization.Data.ServerSyncProvider
Microsoft.Synchronization.Data.Server.DbServerSyncProvider
Microsoft.Synchronization.SyncProvider
Microsoft.Synchronization.Data.ServerSyncProvider
Microsoft.Synchronization.Data.Server.DbServerSyncProvider
The following code example creates a class that derives from DbServerSyncProvider. The class creates a connection and commands to download changes for snapshot synchronization. To view this code in the context of a complete example, see How to: Download a Snapshot of Data to a Client.
Public Class SampleServerSyncProvider Inherits DbServerSyncProvider Public Sub New() 'Create a connection to the sample server database. Dim util As New Utility() Dim serverConn As New SqlConnection(util.ServerConnString) Me.Connection = serverConn 'Create a SyncAdapter for each table, and then define 'the command to select rows from the table. With the Snapshot 'option, you do not download incremental changes. However, 'you still use the SelectIncrementalInsertsCommand to select 'the rows to download for each snapshot. The commands include 'only those columns that you want on the client. 'Customer table. Dim customerSyncAdapter As New SyncAdapter("Customer") Dim customerIncrInserts As New SqlCommand() customerIncrInserts.CommandText = _ "SELECT CustomerId, CustomerName, SalesPerson, CustomerType " _ & "FROM Sales.Customer" customerIncrInserts.Connection = serverConn customerSyncAdapter.SelectIncrementalInsertsCommand = customerIncrInserts Me.SyncAdapters.Add(customerSyncAdapter) 'OrderHeader table. Dim orderHeaderSyncAdapter As New SyncAdapter("OrderHeader") Dim orderHeaderIncrInserts As New SqlCommand() orderHeaderIncrInserts.CommandText = _ "SELECT OrderId, CustomerId, OrderDate, OrderStatus " _ & "FROM Sales.OrderHeader" orderHeaderIncrInserts.Connection = serverConn orderHeaderSyncAdapter.SelectIncrementalInsertsCommand = orderHeaderIncrInserts Me.SyncAdapters.Add(orderHeaderSyncAdapter) 'OrderDetail table. Dim orderDetailSyncAdapter As New SyncAdapter("OrderDetail") Dim orderDetailIncrInserts As New SqlCommand() orderDetailIncrInserts.CommandText = _ "SELECT OrderDetailId, OrderId, Product, Quantity " _ & "FROM Sales.OrderDetail" orderDetailIncrInserts.Connection = serverConn orderDetailSyncAdapter.SelectIncrementalInsertsCommand = orderDetailIncrInserts Me.SyncAdapters.Add(orderDetailSyncAdapter) End Sub 'New End Class 'SampleServerSyncProvider
Development Platforms
For a list of the supported platforms, see Hardware and Software Requirements (Synchronization Services).Target Platforms
Show: