Filter rows in collaboration scenario -- How can I create multiple filters for one table?? RRS feed

  • 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.Tables["Table"].FilterClause = "[side].[name] = '" + scopeName + "'";


    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.
    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


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


    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.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