locked
SyncDirection.Bidirectional? RRS feed

Answers


  • Hi Bill,

    If you take a look at the commands executed on the server when downloading changes to the client you will notice that they all bring down incremental changes from the last sync except those rows that has client id equal to this synchronizing client (self). That said, each client needs to have a unique id that no other client has. The reason you are not getting other client changes is that all clients seems to have an id of 1. To make that work, you need to generate a new number for each client.

    To do a quick test, just compile another client with SelectClientIdCommand equal to "Select 2" ...etc. Now client 1 and client 2 will be able to see each other's changes.

    There are different ways to generate the id; one simple idea is to use the hash of the client GUID.

    Thanks 

    Wednesday, March 14, 2007 5:32 PM
  •  

    The command has to be a valid TSQL statement. Another requirement for SelectClientIdCommand is that it must return int value and not string.

    Wednesday, March 14, 2007 6:51 PM

All replies


  • Hi Bill,

    If you take a look at the commands executed on the server when downloading changes to the client you will notice that they all bring down incremental changes from the last sync except those rows that has client id equal to this synchronizing client (self). That said, each client needs to have a unique id that no other client has. The reason you are not getting other client changes is that all clients seems to have an id of 1. To make that work, you need to generate a new number for each client.

    To do a quick test, just compile another client with SelectClientIdCommand equal to "Select 2" ...etc. Now client 1 and client 2 will be able to see each other's changes.

    There are different ways to generate the id; one simple idea is to use the hash of the client GUID.

    Thanks 

    Wednesday, March 14, 2007 5:32 PM
  •  

    Wednesday, March 14, 2007 6:01 PM
  •  

    The command has to be a valid TSQL statement. Another requirement for SelectClientIdCommand is that it must return int value and not string.

    Wednesday, March 14, 2007 6:51 PM
  •  

    Thursday, March 15, 2007 4:30 AM
  •  

    Hey Rafik! Long time.... hope all is well. Can you look at the below when you get a chance?

     

    How would I add some TSQL to a SyncAdapter to bring down records from a where clause to CE from the server? I want only to sync table data for a specific user... by alias.

     

    I'm working with the below example:

     

    'DEFAULT

    Dim tableProposalDetail As SyncTable = New SyncTable("MyTable")

    tableProposalDetail.CreationOption = TableCreationOption.TruncateExistingOrCreateNewTable

    tableProposalDetail.SyncDirection = SyncDirection.Bidirectional

    '

    Dim orderGroup As SyncGroup = New SyncGroup("AllChanges")

    tableMyTable.SyncGroup = orderGroup

    '

    syncAgent.SyncTables.Add(tableMyTable)

    '

    ' base table

    DetailBuilder.TableName = "MyTable"

    DetailBuilder.DataColumns.Add("tblID")

    DetailBuilder.DataColumns.Add("SQLkey")

    DetailBuilder.DataColumns.Add("CreateDateTime")

    DetailBuilder.DataColumns.Add("Alias")

    DetailBuilder.DataColumns.Add("DNumb")

    DetailBuilder.DataColumns.Add("DRevNumb")

    DetailBuilder.DataColumns.Add("DLine")

    DetailBuilder.DataColumns.Add("create_timestamp")

    DetailBuilder.DataColumns.Add("update_timestamp")

    DetailBuilder.DataColumns.Add("update_originator_id")

    DetailBuilder.DataColumns.Add("create_date")

    '

    Dim DetailBuilderAs SqlSyncAdapterBuilder = New SqlSyncAdapterBuilder()

    DetailBuilder.Connection = serverConnection

    DetailBuilder.SyncDirection = SyncDirection.Bidirectional

    '

    Dim DetailSyncAdapter As SyncAdapter = DetailBuilder.ToSyncAdapter()

    serverSyncProvider.SyncAdapters.Add(DetailSyncAdapter)

     

    ' SORT OF WHAT I'M TRYING TO DO.........................................................................................................

    'code to add the filter as

    syncAgent.CustomParameters.Add(New SyncParameter("@Alias", " '" & GetUserName & "'")) ' to get rows in MyTable

     

    'e.g. your command text as

    serverSyncProvider.SelectClientIdCommand.CommandText = String.Format("select * from MyTable where Alias=@Alias")

    '

    I'd like only to Update/Insert into CE from the SQL Server using a TSQL where clause.

     

    Any ideas?

     

    Thanks,

    billb


    Wednesday, February 6, 2008 5:19 PM