```
connectionString = "SERVER=localhost;DATABASE=NT;UID=" + dbuser + ";PASSWORD=" + dbpass + ";";

connection = new MySqlConnection(connectionString);

OpenConnection();

//open connection to database
    private bool OpenConnection()
    {
        try
        {
            connection.Open();
            return true;
        }
        catch (MySqlException ex)
        {
            //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:
                    Console.WriteLine(" >>>> Cannot contact MySQL Server ");//MessageBox.Show("Cannot connect to server.  Contact administrator");
                    break;

                case 1045:
                    Console.WriteLine(" >>>> Invalid username/password, please try again");
                    break;

                case 1042:
                    Console.WriteLine(" >>>> Unable to resolve DNS");
                    break;
            }
            return false;
        }
    }

```

The code above is successfully connecting to the localhost database and logging in but the database "NT" doesn't exist (which I know) but the ex.Number property is set to 0
I also got the same issue with wrong username/password combo.
The exception message/text gives me the string of the error but the number field is always set to 0. Any help would be greatly appreciated.

Many Thanks,
Ben

EDIT/UPDATE
![enter image description here](https://i.stack.imgur.com/UzSeb.jpg)
![enter image description here](https://i.stack.imgur.com/SAUYr.jpg)

The only difference between the 2 screengrabs is that I changed the NT to test (NT doesn't exist (which the message reports correctly but not the number) and test does exist)

I'm wondering if this is maybe intended behaviour? Is it basically refusing the connection because that DB doesn't exist?