locked
Problem During Row Filtering RRS feed

  • Question

  • I am creating Smart Device Application using MS-Sync Service ado .net v1.
    Currently, i am performing row filtering..

    Following is the code i am using:

    Client Code:

    Public Function InitialSync()

    'Try

    Cursor.Current = Cursors.WaitCursor

    ' The service reference

    Dim webSvcProxy = New TheCyber.Service1

    ' The server provider

    Dim serverProvider = New Microsoft.Synchronization.Data.ServerSyncProviderProxy(webSvcProxy)

    Dim dsClient As String

    Dim dsServer As String

    'Server Side Connection String

    dsServer =
    "Data Source=myservername;Initial Catalog=MobileComputingBusiness;User ID=sa;Password=pswd;"

    Client Side Connection String
    dsClient = (
    "Data Source=" _

    + (System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase), "MobileComputingBusiness.sdf") + ""))

    ' The sync agent

    Dim syncAgent = New LocalDataCache1SyncAgent

    syncAgent.RemoteProvider = serverProvider

    'Sync for Customer Table through WCF Service.

    This is my wcf service..method...providing customer number, device sdf reference, sql server reference respectively.

    '**********************************************************
    webSvcProxy.SyncRows(GetCustomerNo, dsClient, dsServer)]

    '**************************************************** 

    ' Synchronize the databases

    Dim stats = syncAgent.Synchronize()

    MessageBox.Show("Changes Downloaded: " + stats.TotalChangesDownloaded.ToString() + _

    vbCrLf + "Changes Uploaded: " + stats.TotalChangesUploaded.ToString() + _

    vbCrLf + "Sync Start Time: " + stats.SyncStartTime.ToString() + _

    vbCrLf + "Sync End Time: " + stats.SyncCompleteTime.ToString())

    Cursor.Current = Cursors.Default

    End Function
    ------------------------------------------------------------
    SERVER SIDE CODE (WCFServiceLibrary)

    Public Overridable Function SyncRows(ByVal DataContactValue1 As String, ByVal strConnec As String, ByVal strServerConn As String) As CompositeType Implements ILocalDataCache1SyncContract.SyncRows

    Dim conn As New SqlConnection()

    conn.ConnectionString = strServerConn

    Dim agent As New SyncAgent()

    Dim srcProvider As New DbServerSyncProvider()

    Dim dstProvider As SqlCeClientSyncProvider = New SqlCeClientSyncProvider(strConnec)



    ' Set source Provider properties

    Dim AnchorCmd As New SqlCommand()

    AnchorCmd.CommandText = "select * from Customer"

    AnchorCmd.Connection = conn

    Dim filterParameterByApplication As SqlParameter = New SqlParameter(DataContactValue1, SqlDbType.NVarChar)

    ' create sync adapter builder

    Dim adapterBuilder As New SqlSyncAdapterBuilder()

    adapterBuilder.Connection = conn

    'Define Tables

    adapterBuilder.TableName = "Customer"

    adapterBuilder.TombstoneTableName = adapterBuilder.TableName + "_Tombstone"

    adapterBuilder.SyncDirection = SyncDirection.Bidirectional

    'Provide Filter Parameters

    adapterBuilder.FilterClause = "Customer_Number='" & DataContactValue1 & "'"

    adapterBuilder.FilterParameters.Add(filterParameterByApplication)

    adapterBuilder.TombstoneFilterClause = "Customer_Number='" & DataContactValue1 & "'"

    adapterBuilder.TombstoneFilterParameters.Add(filterParameterByApplication)

    Dim adapter As SyncAdapter = adapterBuilder.ToSyncAdapter()

    adapter.SelectIncrementalInsertsCommand = AnchorCmd

    srcProvider.Connection = conn

    srcProvider.SyncAdapters.Add(adapter)

    dstProvider.CreateDatabaseIfNotExists = True

    Dim EmployeeSyncGroup As New SyncGroup("Customer")

    Dim EmployeeSyncTable As New SyncTable("Customer")

    EmployeeSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable

    EmployeeSyncTable.SyncDirection = SyncDirection.Bidirectional

    EmployeeSyncTable.SyncGroup = EmployeeSyncGroup

    agent.Configuration.SyncTables.Add(EmployeeSyncTable)

    agent.LocalProvider = dstProvider

    agent.RemoteProvider = srcProvider

    agent.Synchronize()

    End Function


    PROBLEM:

    I am facing the following problems while performing this Row Filter:

    1) I am getting the following error for local Device sdf database:
    The path is not valid. Check the directory for the database. [ Path = \Program Files\MobileComputingSystem\MobileComputingBusiness.sdf ] 
    2) My other question is whether this is the correct manner for the row filtering in a smart device application.

    • Moved by Hengzhe Li Friday, April 22, 2011 2:39 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, February 24, 2009 9:03 AM

Answers