Using Filters with SyncComm

Feb 3, 2010 at 5:36 PM

I've successfully implemented SyncComm within my project. The server side is hosted in a Windows Forms application and the client side is running on a WM6 device. Currently the device is syncing all rows in the tables from the host database. I would like to filter the data so the device passes up a filter ID to the host and only receives certain records. I've surfed for quite a while and don't see any straightforward or simple implementations of this. Can anyone out there assist?

 

Thanks, Donta

Coordinator
Feb 17, 2010 at 8:23 PM

Hi Donta,

Apologies for delaying. Please check following link from msdn library which explains how to do filtering with sync servervices for ado.net.

If you need furter helpness please feel free to drop it here.

Cheers,

Feb 17, 2010 at 8:30 PM

Thanks for the reply!! I have some working code to post in case someone else out there has the question...

On the server

 SqlParameter filterParameter = new SqlParameter("@driverID", SqlDbType.Int);
 string deliveryFilterClause = "driverID=@driverID";
 
var builder = new SqlSyncAdapterBuilder
{
   ChangeTrackingType = ChangeTrackingType.SqlServerChangeTracking,
   Connection = this.Connection as SqlConnection,
   SyncDirection = SyncDirection.Bidirectional,
   TableName = "Deliveries",
   FilterClause = deliveryFilterClause
                };

builder.FilterParameters.Add(filterParameter);
SyncAdapters.Add(builder.ToSyncAdapter());

On the client

agent.Configuration.SyncParameters.Add(

new SyncParameter("@driverID", Settings.DriverID));