Bug #61653 Loops throwing exception on openning connection when connection details wrong
Submitted: 27 Jun 2011 10:39 Modified: 7 Jul 2011 16:03
Reporter: Mark Glover Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.4.1 OS:Microsoft Windows (Windows 7 64bit)
Assigned to: Julio Casal CPU Architecture:Any

[27 Jun 2011 10:39] Mark Glover
Description:
Loops Throwing First chance exception when connection opened with incorrect connection string entered. This inspite of being in a try catch. 
The open should only throw a single appropriate exception.

How to repeat:
Set wrong database or user details and open a conection
[1 Jul 2011 5:32] Bogdan Degtyariov
Mark,

which exception type is your code catching?
can you copy paste a small code fragment to make it clearer?
Thanks.
[1 Jul 2011 7:50] Mark Glover
It never gets back to the try catch in my code.
But Visual Studio when running in debug displays continuous
"A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll"
This happens if any of the connection string values are wrong.

My code is

try
{
   using (conn = Query.GetConnection())
   {
      Adapter = new MySqlDataAdapter();
      Adapter.SelectCommand = new MySqlCommand(queryString, conn);
      conn.Open(); //******* loops here throwing exceptions *****
      Adapter.Fill(this);
   }
}
catch (MySqlException ex) 
{
   Query.DecodeMySqlException(ex, queryString); // ***** not executed *****
   throw ex;
}

which uses:

static public MySqlConnection GetConnection()
{
   MySqlConnection conn = new MySqlConnection();
   conn.ConnectionString = _ConnectionString;
   return conn;
}

There is another try-catch in the calling routine that catches all exceptions.
That never gets executed.
[7 Jul 2011 16:03] Julio Casal
Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.mysql.com/how-to-report.php

I can't reproduce the bug with the provided information. Please provide a small Visual Studio project with the failing code to review this issue.

If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.