Bug #70100 Error in C# example code
Submitted: 20 Aug 2013 23:13 Modified: 26 Aug 2013 15:42
Reporter: Robert Snow Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Documentation Severity:S3 (Non-critical)
Version: OS:Windows (8.1 Pro Preview 64-bit)
Assigned to: Paul DuBois CPU Architecture:Any

[20 Aug 2013 23:13] Robert Snow
Description:
In the C# section on this page: http://dev.mysql.com/doc/connector-net/en/connector-net-programming-connecting-errors.html the code will produce an error. You need break statements in the switch method or the application will fail to compile.

How to repeat:
MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;
myConnectionString = "server=127.0.0.1;uid=root;" +
    "pwd=12345;database=test;";
try
{
    conn = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString);
    conn.Open();
}
    catch (MySql.Data.MySqlClient.MySqlException ex)
{
    switch (ex.Number)
    {
        case 0:
            MessageBox.Show("Cannot connect to server.  Contact administrator");
        case 1045:
            MessageBox.Show("Invalid username/password, please try again");
    }
}

Suggested fix:
MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;
myConnectionString = "server=127.0.0.1;uid=root;" +
    "pwd=12345;database=test;";
try
{
    conn = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString);
    conn.Open();
}
    catch (MySql.Data.MySqlClient.MySqlException ex)
{
    switch (ex.Number)
    {
        case 0:
            MessageBox.Show("Cannot connect to server.  Contact administrator");
            break;
        case 1045:
            MessageBox.Show("Invalid username/password, please try again");
            break;
    }
}
[23 Aug 2013 12:51] MySQL Verification Team
Thank you for the bug report.
[26 Aug 2013 15:38] Paul DuBois
Reggie confirms the change is correct.
[26 Aug 2013 15:42] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.