public BusinessLayer(string datasource, string database, string username, string password) { string connString = generateConnString(datasource, database, username, password); this.dbSession = ConnectToDb(connString); using (dbSession.activeConn) { try { if (dbSession.activeConn != null) { isLoggedIn = true; Program.connString = connString; } } catch (SqlException ex) { MessageBox.Show("Invalid Username or Password"); Console.WriteLine("Error, " + ex); } } }
/* * public BusinessLayer() * { * this.dbSession = ConnectToDb(); * this.dbSession.activeConn.Close(); * } */ private DbAccessLayer ConnectToDb(string connString) { DbAccessLayer dbSession = new DbAccessLayer(connString); return(dbSession); }