locked
Facing the error the schema for table 'Customer' could not be retrieved by the GetSchema() method of DbServerSyncProvider? in Microsoft sync framework? RRS feed

  • Question

  • Hi All,

    While doing the code for sync sql server database using c#.net, I got the error of the type as shown below

    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

    Please check my code is as below

    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);
    }

    Please help me to fix this issue? please.


    Vaibhav Bhutkar, Jr. .Net Developer, India.

    Tuesday, June 5, 2012 11:12 AM