Microsoft sync Framework RRS feed

  • Question

  • Hi Guys,

    I have an issue with Microsoft Sync Framework.

    I got an error like "Cannot initialize the client database because the schema for table 'Customer' could not be retrieved by the GetSchema() method of DbServerSyncProvider. Ensure that you can establish a connection to the client database, and that either the SelectIncrementalInsertsCommand property or the SelectIncrementalUpdatesCommand property of the SyncAdapter is specified correctly".

    Tuesday, June 5, 2012 9:20 AM

All replies

  • are you using custom tracking or SQL Change Tracking? is the table under a schema under than dbo? does the user have permission on the table?

    Tuesday, June 5, 2012 9:54 AM
  • Hi JuneT,

    Thanks for Reply

    user have permission on table. 

    But i want told you i have two database one DBSyncTest1 is my server database & DBSyncTestClient is my client database.

    DBSynTest1 have- Two tables 1) Customer  2) CustomerContact

    DBSyncTestClient i have one table 1)Customer.

    Tuesday, June 5, 2012 10:14 AM
  • I have used below code ...

    I am unable to connect client database. It is my error. Below i have written connection is this is right way.

    public SampleClientSyncProvider()
                this.ConnectionString = "Data Source=DBSyncTestClient.sdf;LCID=1033; Case Sensitive = TRUE;";

                string[] customerInfoPrimaryKey = new string[1];
                customerInfoPrimaryKey[0] = "CustomerId";
                this.CreatingSchema += new EventHandler<CreatingSchemaEventArgs>(SampleClientSyncProvider_CreatingSchema);
                this.SchemaCreated += new EventHandler<SchemaCreatedEventArgs>(SampleClientSyncProvider_SchemaCreated);

            private void SampleClientSyncProvider_CreatingSchema(object sender, CreatingSchemaEventArgs e)
                Console.Write("Creating schema for " + e.Table.TableName + " | ");

                //Create a compostite primary key for the CustomerInfo table.
                string[] customerInfoPrimaryKey = new string[1];
                customerInfoPrimaryKey[0] = "CustomerId";
                e.Schema.Tables["Customer"].PrimaryKey = customerInfoPrimaryKey;

            private void SampleClientSyncProvider_SchemaCreated(object sender, SchemaCreatedEventArgs e)
                Console.WriteLine("Schema created for " + e.Table.TableName);

    Tuesday, June 5, 2012 11:05 AM
  • your error is not on the client provider. in order to create the schema on the client, the server provider need to query the table on the server to retrieve the schema.

    if you are using the built-in SQL Change Tracking, are you sure it's enabled on the database and table?

    Tuesday, June 5, 2012 11:36 AM
  • Hi JuneT,

    I have checked & enabled the Change tracking to table & database , but i have thrown same error.

    I have written server connection code as :

    SqlConnection serverConn = new SqlConnection("Data Source=;Initial Catalog=DBSyncTest1;uid=sa;pwd=**********;");
                this.Connection = serverConn;


                SyncAdapter customerInfoSyncAdapter = new SyncAdapter("Customer");


                //Select inserts.
                SqlCommand customerInfoIncrementalInsertsCommand = new SqlCommand();
                customerInfoIncrementalInsertsCommand.CommandType = CommandType.Text;
                customerInfoIncrementalInsertsCommand.CommandText =
                    "SELECT * from FROM dbo.Customer";
                customerInfoIncrementalInsertsCommand.Connection = serverConn;
                customerInfoSyncAdapter.SelectIncrementalInsertsCommand = customerInfoIncrementalInsertsCommand;


    Tuesday, June 5, 2012 12:11 PM
  • did you generate the code using the Local Database Cache Wizard or did you hand code the adapters?
    try using SQL Profiler to see what queries are being sent to the database.

    or if you want to use the newer SqlSyncProvider/SqlCeSyncProvider, use the SQL Compact Toolbox to generate the code instead. see: SQL Server Compact Toolbox Sync Framework support

    Tuesday, June 5, 2012 12:30 PM
  • Hi JuneT,

    I have hard coded adapters.

    Tuesday, June 5, 2012 12:55 PM
  • then follow what the error says and check that your SelectIncrementalInserts and SelectIncrementalUpdates commands are setup correctly...
    • Edited by JuneT Tuesday, June 5, 2012 1:18 PM
    Tuesday, June 5, 2012 1:02 PM
  • Hi JuneT,

    Its Resolved the error now. 

    there is some database query problem.

    Thanks for your suggestion & thanks alot !!!!!!!!!!!!!

    Tuesday, June 5, 2012 1:14 PM
  • good to hear that...

    kindly close the other two threads you have opened as they are duplicates of the same issue.

    Tuesday, June 5, 2012 1:19 PM