Answered by:
Filtering problem

Question
-
Good day!
I have successfully implemented MS Sync Framework for my application and wanted to add some optimisations, like rows filtering for a particular table. Unfortunately, I get the following error when I compile the code:
"unable to enumerate changes at the dbserversyncprovider for [table] in synchronization group [syncGroup]"
The error appears after I add the following line: FilterClause = "ID = '" + global.aux + "'", in the following place:
SqlSyncAdapterBuilder[] syncAdapterBuilder = new SqlSyncAdapterBuilder[5]; syncAdapterBuilder[0] = new SqlSyncAdapterBuilder(global.sqlcon) { TableName = "login", ChangeTrackingType = ChangeTrackingType.SqlServerChangeTracking, FilterClause = "ID = '" + global.aux + "'" };
My complete relevant code is:
SqlCeClientSyncProvider sqlceprovider = new SqlCeClientSyncProvider(global.sqlcecon.ConnectionString, false); DbServerSyncProvider sqlprovider = new DbServerSyncProvider(); sqlprovider.Connection = global.sqlcon; SyncAgent syncAgent = new SyncAgent(sqlceprovider, sqlprovider); //--ADD TABLES SyncTable[] tables_to_sync = new SyncTable[5]; tables_to_sync[0] = new SyncTable("login") { CreationOption = TableCreationOption.UseExistingTableOrFail, SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional }; //TABLES 1 TO 4 WHICH WORK PERFECTLY for (int j = 0; j < 5; j++) syncAgent.Configuration.SyncTables.Add(tables_to_sync[j]); //--SET ADAPTER SqlSyncAdapterBuilder[] syncAdapterBuilder = new SqlSyncAdapterBuilder[5]; syncAdapterBuilder[0] = new SqlSyncAdapterBuilder(global.sqlcon) { TableName = "login", ChangeTrackingType = ChangeTrackingType.SqlServerChangeTracking, FilterClause = "ID = '" + global.aux + "'" }; //BUILDERS 1 TO 4 WHICH WORK PERFECTLY SyncAdapter[] syncAdapter = new SyncAdapter[5]; syncAdapter[0] = syncAdapterBuilder[0].ToSyncAdapter(); syncAdapter[0].TableName = "login"; //ADAPTERS 1 TO 4 WHICH WORK PERFECTLY for (int j = 0; j < 5; j++) sqlprovider.SyncAdapters.Add(syncAdapter[j]); //--DEFINE ANCHOR string newAnchorVariable = "@" + SyncSession.SyncNewReceivedAnchor; global.sqlcmd = new SqlCommand("SELECT " + newAnchorVariable + " = min_active_rowversion() - 1", global.sqlcon); global.sqlcmd.Parameters.Add(newAnchorVariable, System.Data.SqlDbType.BigInt); global.sqlcmd.Parameters[newAnchorVariable].Direction = System.Data.ParameterDirection.Output; sqlprovider.SelectNewAnchorCommand = global.sqlcmd; syncAgent.SessionProgress += sync_progress; syncAgent.Synchronize();
Saturday, February 18, 2012 9:20 PM
Answers
-
is ID a PK?
run SQL Profiler so you can see the actual SQL Statement being sent.
if you're using SQL Change Tracking, you might have to specify a table alias since the actual query is doing a join between the table you're synching and the ChangeTable (e.g., FilterClause = "CT.ID = '" + global.aux + "'"
- Marked as answer by Antonius74 Sunday, February 19, 2012 8:52 AM
Sunday, February 19, 2012 12:42 AM
All replies
-
is ID a PK?
run SQL Profiler so you can see the actual SQL Statement being sent.
if you're using SQL Change Tracking, you might have to specify a table alias since the actual query is doing a join between the table you're synching and the ChangeTable (e.g., FilterClause = "CT.ID = '" + global.aux + "'"
- Marked as answer by Antonius74 Sunday, February 19, 2012 8:52 AM
Sunday, February 19, 2012 12:42 AM -
thank you! It seemed that I had to change ID to login.ID to work!Sunday, February 19, 2012 8:53 AM