//private MySqlDataAdapter adapter; public CompteDAO() { try { maConnexion = ConnexionSql.getInstance(provider, dataBase, uid, mdp); } catch (Exception) { throw; } }
public ClientDAO() { try { maConnexion1 = ConnexionSql.getInstance(provider, dataBase, uid, mdp); //maConnexion1.OpenConnection(); } catch (Exception) { throw; } }
/** * 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); } }