SyncDirection.Bidirectional?

Rafik,

I managed to get my deployment issues worked out and running very well after moving the path out of the users folder. The sync class table data is being uploaded to the server from client inserts... the server creating the client database... Very cool stuff!

Here's whats currently going on in my sync process...

  • Each client does write it's data to the SQL 05 server and can be viewed both on the SQL Server and the local CE database.

  • After the Sync completes for each client the CE local database does not contain the others CE local data that was inserted on the SQL 05 Server and in place before Sync was launched on the Client.

  • What triggers the write to the client CE... the __sysChangeTxBsn and __sysInsertTxBsn columns handle the inserts and updates from the Client? The create_timestamp which is set to Now, update_timestamp also set to now, update_originator_id set to 1, and create_date which is set to Now.... these columns?

Which columns do I most need to worry about for updates to and from each client/server... would it be the create_timestamp which is set to Now, update_timestamp also set to now, update_originator_id set to 1, and create_date which is set to Now as well? I have the Default Value or Binding set to (getutcdate()) in the db columns for the DateTime... 1 for the update_originator_id in the 05 SQL Server tables.

What triggers the write to the client CE... the __sysChangeTxBsn and __sysInsertTxBsn columns handle the inserts and updates?

How can I resolve these issues? Thanks for looking... :)

Kind regards,

Bill

[2948 byte] By [billb59] at [2008-2-13]
# 1


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

RafikRobeal at 2007-9-7 > top of Msdn Tech,Visual Studio Orcas,Microsoft Synchronization Services for ADO.NET...
# 2

Hi Rafik,

So if I use something to this effect all should be well?

' client ID command (give the client id of 1)

' in remote server scenario (middle tear), this command will reference a local client table for the ID

Dim clientIdCmd As SqlCommand = New SqlCommand()

clientIdCmd.CommandType = CommandType.Text

'clientIdCmd.CommandText = "SELECT 1" ' old method....

clientIdCmd.CommandText = LocalGetUserName ' this is the name of the users login and unique ent. wide

serverSyncProvider.SelectClientIdCommand = clientIdCmd

Thanks,

Bill

billb59 at 2007-9-7 > top of Msdn Tech,Visual Studio Orcas,Microsoft Synchronization Services for ADO.NET...
# 3

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

RafikRobeal at 2007-9-7 > top of Msdn Tech,Visual Studio Orcas,Microsoft Synchronization Services for ADO.NET...
# 4

How would you write the below for deployment so all sync?

' get client mac address for update_originator_id and clientIdCmd

Dim GetMac As String

GetMac = GetMacAddr().ToString

' select new anchor command

Dim anchorCmd As SqlCommand = New SqlCommand()

anchorCmd.CommandType = CommandType.Text

anchorCmd.CommandText = "SELECT GetDate()"

'

serverSyncProvider.SelectNewAnchorCommand = anchorCmd

'

' client ID command (give the client id of 1)

' in remote server scenario (middle tear), this command will reference a local client table for the ID

'

Dim clientIdCmd As SqlCommand = New SqlCommand()

clientIdCmd.CommandType = CommandType.Text

clientIdCmd.CommandText = "SELECT '" & GetMac & "'"

'clientIdCmd.CommandText = "SELECT 2"

serverSyncProvider.SelectClientIdCommand = clientIdCmd

billb59 at 2007-9-7 > top of Msdn Tech,Visual Studio Orcas,Microsoft Synchronization Services for ADO.NET...

Visual Studio Orcas

Site Classified