Example #1
0
 public static bool Connection_Test(ENTITE.Serveur bean)
 {
     if (bean.Control_())
     {
         NpgsqlConnection con = new NpgsqlConnection();
         try
         {
             string constr = "PORT=" + bean.getPort + ";TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE= 2.0.14.3;DATABASE=" + bean.getDatabase + ";HOST=" + bean.getAdresse + ";PASSWORD="******";USER ID=" + bean.getUser + "";
             con = new NpgsqlConnection(constr);
             con.Open();
             return true;
         }
         catch (NpgsqlException ex)
         {
             Messages.Exception(ex);
             return false;
         }
         finally
         {
             con.Close();
             con.Dispose();
         }
     }
     return false;
 }
Example #2
0
 private static NpgsqlConnection getConnexion(ENTITE.Serveur bean)
 {
     try
     {
         if (bean.Control_())
         {
             NpgsqlConnection con = isConnection(bean);
             con.Open();
             return con;
         }
         else
         {
             if (DialogResult.Retry == Messages.Erreur_Retry("Connexion impossible ! Entrer de nouveaux parametres"))
             {
                 new IHM.Form_Serveur().Show();
             }
         }
     }
     catch (NpgsqlException ex)
     {
         Messages.Exception(ex);
     }
     return null;
 }