MySqlException not trapped in try/catch block

------_=_NextPart_001_01C7A226.838B422D
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

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=3D"You are not owner of thread 58"

Source=3D"MySql.Data"

ErrorCode=3D-2147467259

Number=3D1095

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(CommandBeh avior
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 =3D DateTime.Today;

DateTime datStart =3D datStop.AddDays(-29);



strSQL =3D 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 =3D new MySqlConnection(m_strConnectionString);

objCommand =3D new MySqlCommand(strSQL, objConnection);

objCommand.CommandTimeout =3D 30; // <=3D=3D Can increase to =
60 to
prevent error.

objDataAdapter =3D new MySqlDataAdapter(objCommand);



objConnection.Open();

objDataAdapter.Fill(objDataSet); // <=3D=3D Error occurs =
here.

}

catch (MySqlException MySqlEx)

{

string strMessage =3D MySqlEx.Message; // <=3D=3D Why is is not =
trapped
here??

}

finally

{

// Close the connection to the database if it is open.

if (objConnection.State =3D=3D 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: Randall.Price [at] vt.edu

Phone: (540) 231-4396




------_=_NextPart_001_01C7A226.838B422D--
randallp [ Di, 29 Mai 2007 21:21 ] [ ID #1725055 ]

Re: MySqlException not trapped in try/catch block

On Tue, May 29, 2007 at 03:21:09PM -0400, Price, Randall wrote:
> 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.

Randall,

Please consider posting to the Connector/NET list or forum.

Jess

--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=gcdmo-myodbc [at] m.gmane.org
Jess Balint [ Do, 31 Mai 2007 18:04 ] [ ID #1726929 ]
Datenbanken » gmane.comp.db.mysql.odbc » MySqlException not trapped in try/catch block

Vorheriges Thema: Connector/ODBC installation problem
Nächstes Thema: MyODBC v5 and temporary tables