Esempio n. 1
0
 public static ClsGetdatas GetInstance()
 {
     if (_instance == null)
     {
         _instance = new ClsGetdatas();
     }
     return(_instance);
 }
Esempio n. 2
0
        public void connecter()
        {
            try
            {
                Connexion connexion = new Connexion();

                connexion.Serveur  = File.ReadAllText(ClsConstantes.Table.serveur.ToString()).Trim();
                connexion.Database = File.ReadAllText(ClsConstantes.Table.database.ToString()).Trim();
                connexion.User     = File.ReadAllText(ClsConstantes.Table.user.ToString()).Trim();
                connexion.Password = File.ReadAllText(ClsConstantes.Table.password.ToString()).Trim();

                ImplementeConnexion.Instance.Initialise(connexion, connectionType);
                ImplementeConnexion.Instance.Conn.Open();
                //MessageBox.Show("Connection Succefully !!!", "Succefully", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message);
                ClsGetdatas.GetInstance().Testeconne = 0;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show(ex.Message);
                ClsGetdatas.GetInstance().Testeconne = 0;
            }
            //catch (MySql.Data.MySqlClient.MySqlException ex)
            //{
            //    MessageBox.Show(ex.Message);
            //    clsgetdata.GetInstance().Testeconne = 0;
            //}
            //catch (NpgsqlException ex)
            //{
            //    MessageBox.Show(ex.Message);
            //    clsgetdata.GetInstance().Testeconne = 0;
            //}
            finally
            {
                if (ImplementeConnexion.Instance.Conn != null)
                {
                    if (ImplementeConnexion.Instance.Conn.State == System.Data.ConnectionState.Open)
                    {
                        ImplementeConnexion.Instance.Conn.Close();
                    }
                }
            }
        }