I found a solution. It seems that when you store the connection string in the app.config file, the MySqlException class does not work as expected. However, if you store the connection string in the settings file, it will catch the MySqlException or SQLException depending on which on used. See below.
Try
perform using connstring as type MySqlConnection = new MySqlConnection(type HospitalManagementSoftware.Properties.Settings::Default::connection)
perform using da as type MySqlDataAdapter = new MySqlDataAdapter("LoginUser", connstring)
set da::SelectCommand::CommandType = type CommandType::StoredProcedure
invoke connstring::Open()
set t = new DataTable()
invoke da::Fill(t)
set dataGridView1::DataSource = t
end-perform
end-perform
Catch myex as type MySqlException
set str to str::Append("Source " & myex::Source::ToString)
set str to str::Append("Number " & myex::StackTrace::ToString)
set str to str::Append("Line Number " & myex::TargetSite::ToString)
set str to str::Append("Data Exception " & myex::GetType::ToString)
invoke type Debug::WriteLine(str)
set log to myex::LogString(msg)
invoke type Debug::WriteLine(log)
end-try.