none
SqlSyncProvider connection object problem RRS feed

  • Question

  • Hi,

    I am just wonder is this a bug of SqlSyncProvider? I have 4 database. each one i want to sync between my two server. I have wrote some code as bellow

     

    private void StartStyn()
            {
    
                string TarasimaConnection = ConStrCollection["TaraServer"].ConnectionString;
    
    
             // TarasimaConnection ="Data Source=NOMAN-THINK;Initial Catalog=BitopiSplint;Persist Security Info=True;User ID=sa;Password=*****"
    
               string HQServerconnection = ConStrCollection["HQServer"].ConnectionString;
    
            // HQServerconnection= "Data Source=T1;Initial Catalog=BitopiSplint;Persist Security Info=True;User ID=sa;Password=******"
    
    
                foreach (DataRow OneScope in tblSyncScopeTimerSetting.Rows)
                {
                    SqlConnection clientConn = new SqlConnection(TarasimaConnection);
                    SqlConnection serverConn = new SqlConnection(HQServerconnection);
    
                    if (clientConn.State != ConnectionState.Open)
                    {
                        clientConn.Open();
                        MessageWriter("Client Connection Opened");
                    }
                    if (serverConn.State != ConnectionState.Open)
                    {
                        serverConn.Open(); MessageWriter("Server Connection Opened");
                    }
                                  
                   
                    clientConn.ChangeDatabase(OneScope["DataBaseName"].ToString());
                    // I am changing my database to "Bimob" in the connection object.
                    serverConn.ChangeDatabase(OneScope["DataBaseName"].ToString());
                                    // I am changing my database to "Bimob" in the connection object.
                   
    
                    SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
    
                    pbClient.Value = 0;
                    pbServer.Value = 0;
    
                    // set local provider of orchestrator to a sync provider associated with the
                    // ContactScope in the BitopSplint Server database
                    syncOrchestrator.LocalProvider = new SqlSyncProvider(OneScope["ScopeName"].ToString(), serverConn);
                    MessageWriter("Scope Name:" + OneScope["ScopeName"].ToString());
                    // set the remote provider of orchestrator to a server sync provider associated with
                    // the ContactScope in the Peer2 client database
                    syncOrchestrator.RemoteProvider = new SqlSyncProvider(OneScope["ScopeName"].ToString(), clientConn);
    
              
                    switch (OneScope["Direction"].ToString())
                    {
                        case "Download":
                            syncOrchestrator.Direction = SyncDirectionOrder.Download;
                            break;
                        case "Upload":
                            syncOrchestrator.Direction = SyncDirectionOrder.Upload;
                            break;
                        case "UploadAndDownload":
                            syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;
                            break;
                        case "DownloadAndUpload":
                            syncOrchestrator.Direction = SyncDirectionOrder.DownloadAndUpload;
                            break;
                        default:
                            break;
                    }
                                  
                    SyncOperationStatistics syncStats=null;
    
                    try
                    {
                        syncStats = syncOrchestrator.Synchronize(); ;
                       // Here i am getting error
                    }
                    catch (Exception ex)
                    {
                        MessageWriter(ex.Message.ToString(), true);
                    }
                  
                }
    
            }
    

    when i run this code I am getting following error.

    Cannot find a valid scope with the name 'BiMob Buyer' in table '[scope_info]'. Ensure that this scope exists and that it has a corresponding valid configuration in the configuration table '[scope_config]'.

    I under stand that Sync is not finding my Scope name in targeted database. when i dig in to the code I found that  SqlSyncProvider is making the problem. I changed the database (Bimob) by ChangeDatabase method of Connection object. but still SqlSyncProvider is using the old (BitopiSplint) database with is given as Initial Catalog.

     

    then I change my code a little. I replace the database name in the connection string and then create connection object for SqlSyncProvider. 

    Sync is working fine with this fixing.

     


     

     


    Noman
    Wednesday, January 11, 2012 11:00 AM

All replies

  • have you tried disabling connection pooling?
    Wednesday, January 11, 2012 11:38 AM
    Moderator
  • Actually I am not asking for solution. I need to know is there any mistake in my understanding or it is a bug of Sync Framework.

     


    Ariful Ambia Noman

    Manager MIS

    Bitopi Group

    Wednesday, January 11, 2012 2:16 PM