// COP-OUT METHOD HEADER COMMENT ------------------------------------------------------------------------------- /** * \fn bool OpenConnection() * \brief To create a new Square by validating or else defaulting new values * \details THis is if you have more to say about what the function does and don't want to inline comment * \param[in] none * \param[out] none * \exception MySqlException ex, 0: Cannot connect to server. Contact administrator / 1: Invalid username/password, please try again * \see CallsMade() * \return None * * ---------------------------------------------------------------------------------------------------- */ //open connection to database public bool OpenConnection() { try { connection.Open(); return(true); } catch (MySqlException ex) { //When handling errors, you can your application's response based //on the error number. //The two most common error numbers when connecting are as follows: //0: Cannot connect to server. //1045: Invalid user name and/or password. switch (ex.Number) { case 0: //MessageBox.Show("Cannot connect to server. Contact administrator"); TMSLogger.LogIt("Cannot connect to server. Contact administrator"); break; case 1045: //MessageBox.Show("Invalid username/password, please try again"); TMSLogger.LogIt("Invalid username/password, please try again"); break; } return(false); } }
// COP-OUT METHOD HEADER COMMENT ------------------------------------------------------------------------------- /** * \fn int Square() * \brief To create a new Square by validating or else defaulting new values * \details THis is if you have more to say about what the function does and don't want to inline comment * \param[in] char[] newColour An incoming value meant to become the square's colour * \param[out] char[] newSideLength An incoming value meant to become the square's side length * \exception This is if we have some big ol try catches? * \see CallsMade() * \return None * * ---------------------------------------------------------------------------------------------------- */ //Close connection private bool CloseConnection() { try { connection.Close(); return(true); } catch (MySqlException ex) { TMSLogger.LogIt(ex.Message); return(false); } }
// COP-OUT METHOD HEADER COMMENT ------------------------------------------------------------------------------- /** * \fn bool CloseConnection() * \brief Closes the connection to the SQL database server. * \details Closes the connection to the SQL database server and outputs an exeption to the log and to the screen if a exception is thrown. * \param[in] none * \param[out] none * \exception MySqlException * \see connection.Close() * \return None * * ---------------------------------------------------------------------------------------------------- */ //Close connection public bool CloseConnection() { try { connection.Close(); return(true); } catch (MySqlException ex) { //MessageBox.Show(ex.Message); TMSLogger.LogIt(ex.Message); return(false); } }