private bool ConnectToDatabase(string userName, string password) { int portNum = 3306; //This is the default port for MySQL. if (textPort.Text != "" && !Int32.TryParse(textPort.Text, out portNum)) { MessageBox.Show("Please enter a valid number for the Port."); return(false); } string server = textServer.Text; if (portNum != 3306) { server += ":" + portNum; } try { _dataConnection = DbAdminMysql.ConnectAndTest(userName, password, server); } catch (Exception ex) { MessageBox.Show("Unable to connect to the database. Error message: " + ex.Message); return(false); } SetUsersEnabled(true); return(true); }