Hello, I have a long running query that generates a MySqlException due to the query timing out. It takes about 55 seconds to run on our production server. The MySqlException is NOT being trapped in my try/catch block. Here is the error:
MySql.Data.MySqlClient.MySqlException was unhandled Message="You are not owner of thread 58" Source="MySql.Data" ErrorCode=-2147467259 Number=1095 StackTrace: at MySql.Data.MySqlClient.MySqlStream.OpenPacket() at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId) at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet() at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader() at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() at MySql.Data.MySqlClient.MySqlCommand.Cancel() at MySql.Data.MySqlClient.MySqlCommand.TimeoutExpired(Object commandObject) at System.Threading._TimerCallback.TimerCallback_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading._TimerCallback.PerformTimerCallback(Object state) Here is my C# code: try { DateTime datStop = DateTime.Today; DateTime datStart = datStop.AddDays(-29); strSQL = String.Format( "CALL sp_webReport_Graph_GetUpdatesInstalled_ByDay('{0}', '{1}')", datStart.ToString("yyyy-MM-dd 00:00:01"), datStop.ToString("yyyy-MM-dd 23:59:59")); objConnection = new MySqlConnection(m_strConnectionString); objCommand = new MySqlCommand(strSQL, objConnection); objCommand.CommandTimeout = 30; // <== Can increase to 60 to prevent error. objDataAdapter = new MySqlDataAdapter(objCommand); objConnection.Open(); objDataAdapter.Fill(objDataSet); // <== Error occurs here. } catch (MySqlException MySqlEx) { string strMessage = MySqlEx.Message; // <== Why is is not trapped here?? } finally { // Close the connection to the database if it is open. if (objConnection.State == ConnectionState.Open) objConnection.Close(); // Clean up MySQL objects. objConnection.Dispose(); objDataAdapter.Dispose(); } The error occurs on the line: objDataAdapter.Fill(objDataSet); If I increase the CommandTimeout to 60 it works without error. My question is why does the MySqlException not get handled in my catch block? Thanks, Randall Price Secure Enterprise Technology Initiatives Microsoft Implementation Group Virginia Tech Information Technology 1700 Pratt Drive Blacksburg, VA 24060 Email: [EMAIL PROTECTED] Phone: (540) 231-4396 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]