how do I get the ClientiID in the server sync provider side? RRS feed

  • Question


    Hi Folks


    I am trying to do what I thought would be a simple thing but unfortunately, I've run into a brick wall.


    I have a n-teir sync process, which a WinCE device syncing with a SQLExpress server.  In my ServerSyncProvider (which is hidden behind a webservice), I need to know the GUID of the client (the ClientID) that is syncing to the server.  This is so that I can filter the rows I provide the client.  From the documentation, it seems something like this should work:



    selectNetworks = "Select ID from Networks where ClientGUID = @" + SyncSession.SyncClientId;

    SqlCommand netComm = new SqlCommand(selectNetworks, (SqlConnection) this.Connection);

    netComm.Parameters.Add("@" + SyncSession.SyncClientId, SqlDbType.UniqueIdentifier);

    SqlDataReader rdr = netComm.ExecuteReader();

    StringBuilder sb = new StringBuilder();

    while (rdr.Read())


    sb.Append(rdr["ID"]+",") ;




    The exception I get is as follows (on rdr.Read()):

    Server was unable to process request. ---> System.Data.SqlClient.SqlException: The parameterized query '(@sync_client_id uniqueidentifier)Select ID from Networks where ' expects the parameter '@sync_client_id', which was not supplied.


    This exception makes perfect sense to me, I am not supplying the GUID to the query. 


    So, my question is, on the server sync provider, how do I get the GUID (ClientID) of the client who is syncing?  I apologise if I have missed something obvious, but I can't see it Sad


    I know this property is on the ClientID property of the LocalProvider on the ClientSyncAgent, on the client side, but where is it on the server?




    • Moved by Max Wang_1983 Friday, April 22, 2011 6:39 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Wednesday, August 6, 2008 4:42 PM


  • in your web service code ( or WCF service code ), the web method or the WCF contract you should implement should be GetCHanges(), ApplyChanges etc. one of the parameter to them is the Syncsession object. the syncSession object should has a prooerty ClientID and you can get whatn you need there.


    I assume the code you have above is called during a sync.




    Friday, August 8, 2008 12:47 AM