private void Form1_Load_2(object sender, EventArgs e) { maConnexion = ConnexionSql.getInstance(unProvider, uneDataBase, unUid, unMdp); maConnexion.openConnection(); affiche(); maConnexion.closeConnection(); lbDateJour.Text = GD.getDateDuJour(); }
/** * méthode de création d'une instance de connexion si elle n'existe pas (singleton) */ public static ConnexionSql getInstance(string unProvider, string uneDataBase, string unUid, string unMdp) { lock ((mylock)) { try { if (null == connection) { // Premier appel connection = new ConnexionSql(unProvider, uneDataBase, unUid, unMdp); } } catch (Exception emp) { throw (emp); } return(connection); } }