Exemple #1
0
        /// <summary>
        /// Method initializing the connection to the database's server. This method assume that the configuration file is correct. If the method cannot connect to the server,
        /// a message box pop to prevent the user that there is a problem with its connection.
        /// </summary>
        private bool InitializeConnection()
        {
            string ConnectionString_ST = "";
            bool   Connected_b;

            try
            {
                ConnectionString_ST += "User ID=" + mUserConnexionInfo_O.mUserName_st + "; ";
                ConnectionString_ST += "Persist Security Info=" + mUserConnexionInfo_O.mPersistSecurityInfo_b.ToString() + "; ";
                ConnectionString_ST += "Data Source=" + mUserConnexionInfo_O.mDataSource_st + "; ";
                ConnectionString_ST += "Integrated Security=" + mUserConnexionInfo_O.mIntegratedSecurity_st + "; ";
                ConnectionString_ST += "Initial Catalog=" + mUserConnexionInfo_O.mInitialCatalog_st + "; ";
                ConnectionString_ST += "MultipleActiveResultSets=" + mUserConnexionInfo_O.mMultipleActiveResultSets_b.ToString() + ";";

                mDBManager_O.ConnectDatabase(ConnectionString_ST);
                Connected_b = mDBManager_O.mConnected_b;
            }
            catch (IOException Error_O)
            {
                Connected_b = false;
                System.Diagnostics.Debug.WriteLine("Cannot open connection configuration file.\r\n" + Error_O.ToString());
                MessageBox.Show("Impossible de se connecter au serveur de base de données MMSoft. Veuillez vérifier votre fichier de configuration de connexion " + USER_CONNECTION_CONFIG_FILE + ". Si le fichier de configuration était inexistant il sera recréé.");
            }

            return(Connected_b);
        }