locked
DbSync Exception RRS feed

  • Question

  • When I tried to sync my sql 2008 R2 with Azure, getting an exception and my code lokk like this

    DbSyncTableDescription Customer = SqlSyncDescriptionBuilder.GetDescriptionForTable("myTable", sqllocal);
            
      myScope.Tables.Add(Customer);
    

    "Cannot apply changes because the local provider does not have adapters configured for the following tables that were received from the remote provider: myTable. Ensure that the correct adapters have been added to both providers for Scope 'alltablesyncgroup', and that any table mapping has been correctly configured."

     

    can anybody help me please...

    Monday, February 7, 2011 6:39 AM

Answers

  • Can you take a look at the code sample and walkthrough mentioned here.

    You need to provision the SQL Azure and then use that scope description on the client.


    This posting is provided AS IS with no warranties, and confers no rights
    Thursday, February 17, 2011 9:22 PM

All replies

  • can you post additional code snippets?
    Monday, February 7, 2011 12:25 PM
  • using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    using System.Data.SqlClient;
    using Microsoft.Synchronization.Data.SqlServer;
    using Microsoft.Synchronization.Data;
    using Microsoft.Synchronization;
    
    
    namespace SyncTest
    {
      class Program
      {
        public static string sqlazureConnectionString = "Server=******.database.windows.net;Database=Sync_Test1;User ID=myid@database.windows.net;Password=*****;Trusted_Connection=False;Encrypt=True";
        
        public static string sqllocalConnectionString = "Server=mysql\\SQLEXPRESS;Database=Sync_LOCAL;Trusted_Connection=True";
        
        public static readonly string scopeName = "alltablesyncgroup";
    
        static void Main(string[] args)
        {
                  Setup();
          
            Sync();
    
        }
        public static void Setup()
        {
          try
          {
     
            SqlConnection sqlServerConn = new SqlConnection(sqllocalConnectionString);
            SqlConnection sqlAzureConn = new SqlConnection(sqlazureConnectionString);
            sqlAzureConn.Open();
            sqlServerConn.Open();
            DbSyncScopeDescription myScope = new DbSyncScopeDescription(scopeName);
    
            SqlCommand cmd = new SqlCommand("select * from sysobjects where type='u'", sqlServerConn);
            SqlDataReader myReader = cmd.ExecuteReader();
            SqlConnection sqllocal = new SqlConnection(sqllocalConnectionString);
            sqllocal.Open();
    
            while (myReader.Read())
            {
    
              DbSyncTableDescription Customer = SqlSyncDescriptionBuilder.GetDescriptionForTable(myReader["name"].ToString(), sqllocal);
                  myScope.Tables.Add(Customer);
            }
            myReader.Close();
    
     
           
             SqlSyncScopeProvisioning sqlServerProv = new SqlSyncScopeProvisioning(sqllocal, myScope);
            if (!sqlServerProv.ScopeExists(scopeName))
            {
                 Console.WriteLine("Provisioning SQL Server for sync " + DateTime.Now);
              sqlServerProv.Apply();
              Console.WriteLine("Done Provisioning SQL Server for sync " + DateTime.Now);
            }
            else
              Console.WriteLine("SQL Server Database server already provisioned for sync " + DateTime.Now);
     
                   SqlSyncScopeProvisioning sqlAzureProv = new SqlSyncScopeProvisioning(sqlAzureConn, myScope);
            if (!sqlAzureProv.ScopeExists(scopeName))
            {
             .
              Console.WriteLine("Provisioning SQL Azure for sync " + DateTime.Now);
              sqlAzureProv.Apply();
              Console.WriteLine("Done Provisioning SQL Azure for sync " + DateTime.Now);
            }
            else
              Console.WriteLine("SQL Azure Database server already provisioned for sync " + DateTime.Now);
     
            sqlAzureConn.Close();
            sqlServerConn.Close();
          }
          catch (Exception ex)
          {
            Console.WriteLine(ex);
          }
        }
     
        public static void Sync()
        {
          try
          {
     
            SqlConnection sqlServerConn = new SqlConnection(sqllocalConnectionString);
            SqlConnection sqlAzureConn = new SqlConnection(sqlazureConnectionString);
            SyncOrchestrator orch = new SyncOrchestrator
            {
              LocalProvider = new SqlSyncProvider(scopeName, sqlAzureConn),
              RemoteProvider = new SqlSyncProvider(scopeName, sqlServerConn),
              Direction = SyncDirectionOrder.UploadAndDownload
            };
            Console.WriteLine("ScopeName={0} ", scopeName.ToUpper());
            Console.WriteLine("Starting Sync " + DateTime.Now);
            ShowStatistics(orch.Synchronize());
    
            sqlAzureConn.Close();
            sqlServerConn.Close();
          }
          catch (Exception ex)
          {
            Console.WriteLine(ex);
          }
        }
    

    and i have around 200 tables and some of them having 150000 rows...and getting this

     

    "Cannot apply changes because the local provider does not have adapters configured for the following tables that were received from the remote provider: myTable. Ensure that the correct adapters have been added to both providers for Scope 'alltablesyncgroup', and that any table mapping has been correctly configured."

     

    Monday, February 7, 2011 12:59 PM
  • Hi Sharon,

    Does myTable exist on SQL Azure, and are you configuring multiple scopes?

    Thanks,

    Minh.

    Wednesday, February 9, 2011 11:42 PM
  • Can you take a look at the code sample and walkthrough mentioned here.

    You need to provision the SQL Azure and then use that scope description on the client.


    This posting is provided AS IS with no warranties, and confers no rights
    Thursday, February 17, 2011 9:22 PM