Answered by:
Filter rows in collaboration scenario -- How can I create multiple filters for one table??

Question
-
Hi everybody!
I hope you can understand my poor English :<
Now I want to realize a function like this:
In the client(sql 2005 express), I just sync data for specified user(userA or userB, etc).
How can I create multiple filters for userA/B/C...?
Here is my code:
...
string scopeName == "UserA";// or userB, etc. It will be changed.
DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription(scopeName);
SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning();
if (!serverConfig.ScopeExists(scopeName, connServer))
{
scopeDesc.Tables.Add(SqlSyncDescriptionBuilder.GetDescriptionForTable("Table", connServer));
serverConfig.PopulateFromScopeDescription(scopeDesc);
serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);
serverConfig.Tables["Table"].AddFilterColumn("name");
serverConfig.Tables["Table"].FilterClause = "[side].[name] = '" + scopeName + "'";
serverConfig.Apply(connServer);
}
...
At the first time it always works well. But if I change the scopeName's value, there will be a exception "..._tracking tables already exist".
There is a article which describe the same problem. But its "answers" can't help me.
http://social.microsoft.com/Forums/en-US/syncdevdiscussions/thread/65d1e966-f4fb-44c4-9189-9d5d6c0f69e2
I don't want to drop these DB object manually! And when I accord to the second answer, the result of sync is not correct. Because I found the sp "_selectchanges"'s script which generated at the first time contains the first scopeName's value.
What should I do?
Thanks a lot!
超级宇宙无敌旋风猪!~Friday, July 23, 2010 2:46 AM
Answers
-
The SqlSyncProvider doesnt support dynamically passing the filter value (the filter column and value is hardcoded in the selectchanges sp).
You can create one scope for each filter value but you need to specify that you want to skip creation of some Sync objects. check out this post on how to go about it: http://jtabadero.spaces.live.com/blog/cns!BF49A449953D0591!1184.entry
- Marked as answer by 大大泡泡猪 Friday, July 23, 2010 6:20 AM
Friday, July 23, 2010 3:02 AM
All replies
-
The SqlSyncProvider doesnt support dynamically passing the filter value (the filter column and value is hardcoded in the selectchanges sp).
You can create one scope for each filter value but you need to specify that you want to skip creation of some Sync objects. check out this post on how to go about it: http://jtabadero.spaces.live.com/blog/cns!BF49A449953D0591!1184.entry
- Marked as answer by 大大泡泡猪 Friday, July 23, 2010 6:20 AM
Friday, July 23, 2010 3:02 AM -
Thank you very much for your help!
Now I add some code below "serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);"
serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);
serverConfig.SetCreateTrackingTableDefault(DbSyncCreationOption.Skip);
serverConfig.SetCreateTriggersDefault(DbSyncCreationOption.Skip);
serverConfig.SetCreateProceduresDefault(DbSyncCreationOption.Skip);
//serverConfig.SetPopulateTrackingTableDefault(DbSyncCreationOption.Skip);
serverConfig.SetCreateProceduresForAdditionalScopeDefault(DbSyncCreationOption.Create); //it create a new sp named "..._selectchanges_xxxxxxxxxxxxxxxxxxxxxx" for us and we can find it in the scope_config.config_data.
....
超级宇宙无敌旋风猪!~Friday, July 23, 2010 6:49 AM