My C# program works with a MySQL database.
For some reason the program cannot catch exceptions caused my the MySQL connection.
Example:
If I make the
Use the appropriate exception type in the catch block.
Use the appropriate MySQL classes.
using MySql.Data.MySqlClient;
// class level var or whatnot:
string connString = @"server=theHostName;userid=dbuser123;password=OpenSesame7;database=my_db_name";
public void connect()
{
try
{
conn = new MySqlConnection(connString); // read above comments for (conn)
conn.Open();
}
catch (MySqlException ex)
{
MessageBoxButtons buttons = MessageBoxButtons.OK;
string s="MySqlException: "+ex.ToString();
MessageBox.Show(s,"Error",buttons);
}
finally
{
if (conn != null)
{
//conn.Close();
}
}
}
Error Caught No Problem:
Add References screenshot: